Skip to content

fix: keep multi-select ComboBox selection when Tab closes the popover - #10983

Open
mvanhorn wants to merge 1 commit into
adobe:mainfrom
mvanhorn:fix/10974-combobox-multiple-tab-selection
Open

mvanhorn wants to merge 1 commit into
adobe:mainfrom
mvanhorn:fix/10974-combobox-multiple-tab-selection

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

It addresses the behavior reported in issue #10974.

fix: keep multi-select ComboBox selection when Tab closes the popover

Closes #10974

📝 Test Instructions

The targeted tests for the react-spectrum useComboBox change pass locally.
The tests in packages/react-aria-components/test/ComboBox.test.js and packages/react-aria/test/combobox/useComboBox.test.js fail without the fix in the react-spectrum useComboBox change (checked by reverting the source changes).
Regression check for the react-spectrum useComboBox change: 4 fail on main, all 61 pass with the fix; hosted CI not run.

Release impact

  • Only changes docs, tests, CI, or development tools. Nothing shipped to users changes.
  • Fixes a bug or improves existing code without changing how apps use it.
  • Adds a feature or API while keeping existing usage working.
  • May break existing usage or require changes in apps that use this code.

✅ PR Checklist

  • I followed the contributing guide.
  • I tested this change locally and included the results in Test Instructions, or explained why testing does not apply.
  • I understand and can explain every change in this PR. If I used AI assistance, I followed the AI contribution guidance.

🧢 Your Project

Not applicable to this change.

AI was used for assistance.

@isihussain isihussain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review: Multi-Axis Evaluation

Excellent attention to keyboard interaction details @mvanhorn! In multi-select ComboBox, pressing Tab should dismiss the popover without toggling or selecting the focused item.


1. Interaction Model & Keyboard Semantics

  • Commit vs Close:
    • In single-select mode, Tab committing the focused item matches user expectations.
    • In multi-select mode, options are explicitly toggled via Space or Enter. Calling state.commit() on Tab inadvertently selected whatever option happened to be under focus, frustrating users navigating forms via keyboard.
  • Targeted Condition:
    if (props.selectionMode === 'multiple') {
      state.close();
    } else {
      state.commit();
    }
    cleanly differentiates the modes while preserving existing single-select behavior.

2. Test Verification

  • The test suites in packages/react-aria-components/test/ComboBox.test.js and packages/react-aria/test/combobox/useComboBox.test.js thoroughly assert that {Tab} and {Shift>}{Tab} preserve selected keys and call close instead of commit.

Summary: Perfect keyboard navigation fix for multi-select combo boxes. Strongly approve!

@snowystinger snowystinger left a comment

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.

I think this seems correct. Thanks

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.

ComboBox with mode multiple (un)selects focused item on tab

3 participants