Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 308fe82

Browse filesBrowse files
fix(SelectPanel): do not depend on id for selection comparison (#5986)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c359028 commit 308fe82
Copy full SHA for 308fe82

File tree

2 files changed

+9
-2
lines changed
Filter options

2 files changed

+9
-2
lines changed

‎.changeset/fluffy-squids-hug.md

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
fix(SelectPanel): do not depend on id for selection comparison

‎packages/react/src/SelectPanel/SelectPanel.tsx

Copy file name to clipboardExpand all lines: packages/react/src/SelectPanel/SelectPanel.tsx
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,13 @@ function Panel({
391391
// For single-select modal, there is an intermediate state when the user has selected
392392
// an item but has not yet saved the selection. We need to check for this state.
393393
if (isSingleSelectModal) {
394-
return intermediateSelected?.id === item.id
394+
return intermediateSelected?.id !== undefined
395+
? intermediateSelected.id === item.id
396+
: intermediateSelected === item
395397
}
396398

397399
// For single-select anchored, we just need to check if the item is the selected item
398-
return selected?.id === item.id
400+
return selected?.id !== undefined ? selected.id === item.id : selected === item
399401
},
400402
[selected, intermediateSelected, isSingleSelectModal],
401403
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.