Skip to content

fix(ComboBox): avoid extra onSelectionChange calls#9729

Open
reidbarber wants to merge 1 commit intomainfrom
combobox-fix-extra-onSelectionChange-calls
Open

fix(ComboBox): avoid extra onSelectionChange calls#9729
reidbarber wants to merge 1 commit intomainfrom
combobox-fix-extra-onSelectionChange-calls

Conversation

@reidbarber
Copy link
Member

Closes #9727

Before:

  • Selecting an option fired onSelectionChange once (expected)
  • Clicking away fired it one extra time
  • Tabbing away fired it two extra times

After:

  • No extra onSelectionChange calls occur when values are already in sync

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Unit tests should cover, but smoke test in storybook.

🧢 Your Project:

@github-actions github-actions bot added the RAC label Mar 3, 2026
@rspbot
Copy link

rspbot commented Mar 3, 2026

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

doing some testing still, but do you know if this was a regression? Feels like didn't use to happen...

EDIT: has been happening since last Feb at least, so probably not a regression

expect(preventDefault).toHaveBeenCalledTimes(1);
});

it('should only call commit on Tab when the menu is open', function () {
Copy link
Member

Choose a reason for hiding this comment

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

is this still true if it allows a custom value?

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 useComboBoxState will still clear the selected key on field blur via

still

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RAC ComboBox] onSelectionChange is called extra times when focus is changed after selection (fully controlled)

4 participants