Skip to content

feat: allow custom react element for S2 Picker value#9541

Merged
LFDanLu merged 12 commits intoadobe:mainfrom
BrknRules:S2-Picker-renderValue
Feb 13, 2026
Merged

feat: allow custom react element for S2 Picker value#9541
LFDanLu merged 12 commits intoadobe:mainfrom
BrknRules:S2-Picker-renderValue

Conversation

@BrknRules
Copy link
Contributor

@BrknRules BrknRules commented Jan 28, 2026

This adds a renderValue prop to Picker S2, which allows users to render custom elements within the Picker's select based off of selected items.

* Custom renderer for the selected value shown in the button.
* Matches the `SelectValue` children render type.
*/
renderValue?: SelectValueProps<T>['children']
Copy link
Member

Choose a reason for hiding this comment

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

I think we should just pass in the selected items (i.e. (selectedItems: T[]) => ReactNode) here, and only call it when there is at least one item selected. We already have the placeholder prop to customize the placeholder text, and you can omit renderValue if you want the default text. Is that sufficient for your use case or did you need one of the other render props?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's enough for our use case -- was probably being too proactive trying to think of a general situation.

@BrknRules BrknRules force-pushed the S2-Picker-renderValue branch from 0645caf to 7f8c3fd Compare February 3, 2026 10:57
@BrknRules BrknRules force-pushed the S2-Picker-renderValue branch from 7f8c3fd to d5c4f3c Compare February 3, 2026 11:31
@BrknRules BrknRules requested a review from devongovett February 3, 2026 11:52
Copy link
Contributor Author

@BrknRules BrknRules left a comment

Choose a reason for hiding this comment

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

Some notes on implementation choices -- would appreciate thoughts!

display: 'flex',
alignItems: 'center'
alignItems: 'center',
height: '100%'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Locked height to picker button height. Enough for our use case as we don't have anything larger than the button that should cause it to resize.

@BrknRules BrknRules marked this pull request as ready for review February 4, 2026 10:21
@BrknRules BrknRules requested a review from devongovett February 6, 2026 18:59
Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Looks good. Couple lint/ts issues.

@BrknRules BrknRules requested a review from devongovett February 9, 2026 10:59
@BrknRules BrknRules force-pushed the S2-Picker-renderValue branch from 58c16a4 to 7aeefae Compare February 9, 2026 11:21
@BrknRules BrknRules closed this Feb 9, 2026
@BrknRules BrknRules reopened this Feb 9, 2026
@github-project-automation github-project-automation bot moved this from 🩺 To Triage to ✅ Done in RSP Component Milestones Feb 9, 2026
@github-project-automation github-project-automation bot moved this from ✅ Done to ✏️ To Groom in RSP Component Milestones Feb 9, 2026
@BrknRules BrknRules closed this Feb 9, 2026
@github-project-automation github-project-automation bot moved this from ✏️ To Groom to ✅ Done in RSP Component Milestones Feb 9, 2026
@BrknRules BrknRules reopened this Feb 9, 2026
@github-project-automation github-project-automation bot moved this from ✅ Done to ✏️ To Groom in RSP Component Milestones Feb 9, 2026
@snowystinger snowystinger changed the title wip: allow custom react element for S2 Picker value feat: allow custom react element for S2 Picker value Feb 10, 2026
@snowystinger snowystinger removed the v3 label Feb 10, 2026
@github-actions github-actions bot added the v3 label Feb 10, 2026
Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

To note for testing:

In Chrome VO, there seems to be an issue where it thinks there is an interactive element inside the docs example's button. There is not, and the associated warning does not appear in Safari

Chromatic green: https://www.chromatic.com/build?appId=5f0dd5ad2b5fc10022a2e320&number=1116

@snowystinger snowystinger removed the v3 label Feb 10, 2026
@matthewdeutsch matthewdeutsch moved this from ✏️ To Groom to 👀 In Review in RSP Component Milestones Feb 10, 2026
@snowystinger snowystinger self-assigned this Feb 10, 2026
Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

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

Looks good! Nothing blocking

Comment on lines +556 to +558
const renderedValue = selectedItems.length > 0 && renderValue
? renderValue(selectedValues)
: defaultRenderedValue;
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be selectedValues.length > 0 to prevent the edge case if you had all null items. Super edge case though, I don't even think null items is something we'd care to support.

Comment on lines +362 to +366
<div style={{display: 'flex', gap: 4, height: '80%'}}>
{selectedItems.map(item => (
<img key={item.id} src={item.icon} alt={item.label} />
))}
</div>
Copy link
Member

Choose a reason for hiding this comment

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

Good example, we could probably use AvatarGroup here.

Comment on lines +271 to +275
<div className={style({ display: 'flex', gap: 4, height: '80%' })}>
{selectedItems.map(item => (
<Avatar slot={null} key={item.id} src={item.avatar} alt={item.name} />
))}
</div>
Copy link
Member

Choose a reason for hiding this comment

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

Same, maybe AvatarGroup would better since it's an established pattern.

@reidbarber reidbarber added this pull request to the merge queue Feb 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2026
@LFDanLu LFDanLu added this pull request to the merge queue Feb 13, 2026
Merged via the queue into adobe:main with commit 175929e Feb 13, 2026
29 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in RSP Component Milestones Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants