Skip to content

Fix multiple dropdown selected value display#36136

Open
brianchristopherbrady wants to merge 1 commit into
masterfrom
user/brianbrady/dropdown-handling-multiple-options
Open

Fix multiple dropdown selected value display#36136
brianchristopherbrady wants to merge 1 commit into
masterfrom
user/brianbrady/dropdown-handling-multiple-options

Conversation

@brianchristopherbrady
Copy link
Copy Markdown
Contributor

@brianchristopherbrady brianchristopherbrady commented May 8, 2026

Summary

Updates web-components dropdown multiple selection so selected values are displayed as a comma-separated list and can wrap in the trigger, matching the expected visual behavior.

Changes

  • Displays all selected multiple dropdown options instead of a compact count summary.
  • Allows multiple dropdown button text to wrap while keeping the indicator stable.
  • Initializes default selected dropdown options when listbox options populate.
  • Updates the multiple-selection story to show the Best pet example.
  • Adds tests for initial and interactive multiple selection display.

Validation

  • Verified the multiple-selection Storybook story and Dropdown Docs page show Cat, Dog, Fish, Hamster, Snake, Bird, Wolf, Beetle, Squirrel with a wrapped trigger.
  • VS Code diagnostics passed for the edited dropdown/listbox files.

Note: focused Yarn e2e could not run locally because this checkout currently has a Yarn workspace lockfile mismatch before tests start.

Screnshot

image

@brianchristopherbrady brianchristopherbrady requested a review from a team as a code owner May 8, 2026 20:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📊 Bundle size report

✅ No changes found

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Pull request demo site: URL

Comment on lines +87 to +102
if (this.dropdown) {
option.multiple = !!this.multiple;
option.disabled = option.disabledAttribute || this.dropdown.disabled;
option.name = this.dropdown.name;
}
});

if (this.dropdown) {
next
?.filter(option => option.defaultSelected)
.forEach((option, index) => {
option.selected = !!this.multiple || index === 0;
});

this.dropdown.setValidity();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this related? It seems like the primary change here needs to be styles.

The dropdown when constrained to space wraps to another line (the intent of this PR). It seems like this could be a max-width issue either in the component or example. I'm not sure what the logic changes are here.

Image

@@ -0,0 +1,7 @@
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-web-components/Accordion 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Accordion. - Dark Mode.normal.chromium_1.png 3154 Changed
vr-tests-web-components/Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Badge. - Dark Mode.normal.chromium.png 443 Changed
vr-tests-web-components/MenuList 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/MenuList. - Dark Mode.normal.chromium.png 498 Changed
vr-tests-web-components/MenuList. - RTL.2nd selected.chromium.png 17 Changed
vr-tests-web-components/RadioGroup 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/RadioGroup. - Dark Mode.1st selected.chromium_2.png 119 Changed

const displayValue = this.listFormatter.format(this.selectedOptions.map(x => x.text));
const selectedOptions = this.selectedOptions;
const displayValue = this.multiple
? selectedOptions.map(x => x.text).join(', ')
Copy link
Copy Markdown
Contributor

@marchbox marchbox May 8, 2026

Choose a reason for hiding this comment

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

I think we do want to use the list formatter for multiple, joining the text with a comma and a whitespace will not work internationally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants