Skip to content

#490 - Select: multiple mode closes the dropdown after every selection - #491

Open
jaieds wants to merge 1 commit into
component-improvements/editor-inputfrom
fix/select-multiselect-keep-open
Open

#490 - Select: multiple mode closes the dropdown after every selection#491
jaieds wants to merge 1 commit into
component-improvements/editor-inputfrom
fix/select-multiselect-keep-open

Conversation

@jaieds

@jaieds jaieds commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closes #490

What

  • multiple mode: dropdown stays open after an option is clicked or toggled via Enter/Space, so several options can be picked without reopening.
  • Clicking an already-selected option now deselects it (toggle) without closing.
  • Escape and outside click still close the list via Floating UI useDismiss (unchanged); focus returns to the trigger through FloatingFocusManager.
  • Single mode unchanged: closes on select.

How

handleMultiSelect in select.tsx no longer calls setIsOpen(false) or refocuses the trigger, and the early-return for already-selected values is replaced with a splice (deselect). Checkmarks/badges update live since option checked state derives from getValues().

Tests

  • Updated MultiSelect and InlineSearchMulti play tests: keep-open assertions after each pick, toggle-deselect without close, Escape closes.
  • Full vitest storybook suite: 82 files / 251 tests green.
  • Manual E2E in Chrome against Storybook: multi keep-open, toggle-deselect, Escape close, outside-click close, reopen persists selection, single mode closes on select. No console errors.

Notes

Selecting an option in multiple mode no longer closes the dropdown, and
clicking an already-selected option deselects it. Escape and outside
click (useDismiss) still close the list; single mode still closes on
select. Updated MultiSelect and InlineSearchMulti story play tests to
assert the keep-open and toggle behavior.
@jaieds jaieds self-assigned this Aug 3, 2026
@@ -248,17 +248,25 @@ MultiSelect.play = async ( { canvasElement } ) => {
const listBox = await screen.findByRole( 'listbox' );
expect( listBox ).toHaveTextContent( 'Red' );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What: You should verify if the listbox remains open with selected options before each interaction.

Why: This would ensure that you account for the dropdown's state in all test assertions, which is crucial to confirm the component functions correctly as intended in multiple selection mode.

How: Consider adding assertions to check the state of the listbox after clicking each option, for example using expect(screen.queryByRole('listbox')).not.toBeNull(); before subsequent interactions.

expect( screen.queryByRole( 'listbox' ) ).not.toBeNull();
await userEvent.click( allOptions[ 1 ] ); // Orange
expect( screen.queryByRole( 'listbox' ) ).not.toBeNull();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What: Ensure you validate state change rigorously for toggling options.

Why: Confirming that the deselecting of an already selected item reflects correctly in the button text is essential for both correctness and maintainability.

How: Continue using your pattern of expect( selectButton ).toHaveTextContent(...) to assert the button text updates as expected after a toggle action.


// Clicking an already-selected option deselects it without closing
await userEvent.click( allOptions[ 1 ] ); // Orange (toggle off)
expect( screen.queryByRole( 'listbox' ) ).not.toBeNull();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What: The events concerning the Escape key should be adequately tested in isolation as well to ensure no other interactions interfere with its function.

Why: This adds robustness to your tests, ensuring that all possible user interactions are accounted for, enhancing confidence in the dropdown functionality.

How: Consider adding a similar test case that explicitly focuses on the Escape key functionality after clicking multiple options.

@jaieds jaieds linked an issue Aug 3, 2026 that may be closed by this pull request
@jaieds
jaieds requested a review from imnavanath August 3, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select: multiple mode closes the dropdown after every selection

1 participant