Skip to content

fix(SelectPanel): do not depend on id for selection comparison #5986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 30, 2025

Conversation

francinelucca
Copy link
Member

@francinelucca francinelucca commented Apr 30, 2025

Fixes bug where items without an id where being shown as selected when they weren't. Example: https://primer.style/product/components/select-panel/#single-select

image

Changelog

Changed

  • Use the entire item object for comparison on selection when the id is not present

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

Copy link

changeset-bot bot commented Apr 30, 2025

🦋 Changeset detected

Latest commit: d9baeee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the staff Author is a staff member label Apr 30, 2025
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Apr 30, 2025
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

github-actions bot commented Apr 30, 2025

Uh oh! @francinelucca, at least one image you shared is missing helpful alt text. Check your pull request body to fix the following violations:

  • Images should have meaningful alternative text (alt text) at line 7

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

Copy link
Contributor

github-actions bot commented Apr 30, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 98.94 KB (+0.04% 🔺)
packages/react/dist/browser.umd.js 99.08 KB (-0.07% 🔽)

@github-actions github-actions bot requested a deployment to storybook-preview-5986 April 30, 2025 18:28 Abandoned
@francinelucca francinelucca marked this pull request as ready for review April 30, 2025 18:30
@Copilot Copilot AI review requested due to automatic review settings April 30, 2025 18:30
@francinelucca francinelucca requested a review from a team as a code owner April 30, 2025 18:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue in the SelectPanel where items without an id were being incorrectly marked as selected by comparing using the id property.

  • Updated comparison logic on both intermediateSelected (for single-select modal) and selected (for anchored select) items, using the entire item for comparison when id is absent.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/react/src/SelectPanel/SelectPanel.tsx Modified item equality comparison logic to avoid reliance solely on id
.changeset/fluffy-squids-hug.md Added changeset for the patch release

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@francinelucca francinelucca requested a review from Copilot April 30, 2025 18:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the SelectPanel where items without an id were being incorrectly shown as selected, by switching the comparison to use the entire item object when needed.

  • The single-select modal comparison is now modified to check for an id before falling back to object equality.
  • The single-select anchored comparison has a similar update to compare the full object when an id is absent.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/react/src/SelectPanel/SelectPanel.tsx Updates selection comparison logic to fall back to object equality when id is absent.
.changeset/fluffy-squids-hug.md Adds a changeset entry indicating a patch release for the SelectPanel bug fix.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions bot temporarily deployed to storybook-preview-5986 April 30, 2025 18:42 Inactive
@github-actions github-actions bot requested a deployment to storybook-preview-5986 April 30, 2025 18:49 Abandoned
Copy link
Contributor

@hectahertz hectahertz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre approving, check comments!

Merged via the queue into main with commit 308fe82 Apr 30, 2025
41 checks passed
@francinelucca francinelucca deleted the fix/selectpanel-atch branch April 30, 2025 19:17
@primer primer bot mentioned this pull request Apr 30, 2025
hectahertz pushed a commit that referenced this pull request May 20, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy