Skip to content

Commit 308fe82

Browse files
fix(SelectPanel): do not depend on id for selection comparison (#5986)
Co-authored-by: Copilot <[email protected]>
1 parent c359028 commit 308fe82

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/fluffy-squids-hug.md

Lines 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

Lines 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)