Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rude-jokes-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added the `key` prop to `Select` component `StrictOption`
6 changes: 4 additions & 2 deletions polaris-react/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface StrictOption {
disabled?: boolean;
/** Element to display to the left of the option label. Does not show in the dropdown. */
prefix?: React.ReactNode;
/** Unique key applied to the option element. Defaults to option value prop when undefined. */
key?: string;
}

interface HideableStrictOption extends StrictOption {
Expand Down Expand Up @@ -272,9 +274,9 @@ function flattenOptions(
}

function renderSingleOption(option: HideableStrictOption): React.ReactNode {
const {value, label, prefix: _prefix, ...rest} = option;
const {value, label, prefix: _prefix, key, ...rest} = option;
return (
<option key={value} value={value} {...rest}>
<option key={key ?? value} value={value} {...rest}>
{label}
</option>
);
Expand Down