Skip to content

fix: combobox interactoutside#9646

Open
snowystinger wants to merge 2 commits intomainfrom
fix-combobox-interactoutside
Open

fix: combobox interactoutside#9646
snowystinger wants to merge 2 commits intomainfrom
fix-combobox-interactoutside

Conversation

@snowystinger
Copy link
Member

Closes #5338

Also fixes an issue where a combobox inside of a shadow dom couldn't be closed by clicking outside, seen here
#9632

✅ 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:

In the new story

  1. open dialog
  2. open combobox
  3. click outside on the dialog's underlay
  4. it should close

🧢 Your Project:

@rspbot
Copy link

rspbot commented Feb 12, 2026

Comment on lines +371 to +380
useInteractOutside({
ref: popoverRef,
onInteractOutside: (e) => {
if (nodeContains(buttonRef?.current, getEventTarget(e) as Element)) {
return;
}
state.close();
},
isDisabled: !state.isOpen
});
Copy link
Member

Choose a reason for hiding this comment

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

This will cause the combobox to close its dropdown if the user clicks in the input field to move the text cursor while the input field is open, thus also clearing the input value prematurely. To reproduce, try going to https://reactspectrum.blob.core.windows.net/reactspectrum/00b9c9579f9dbff5d7f0a850d1add047a221832c/storybook-s2/index.html?path=/docs/combobox--docs, typing "Mi", then trying to click inbetween "M" and "i" to move the cursor

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thanks, didn't know that was a user flow. I think we can adjust for that by checking if it's the input

Copy link
Member

Choose a reason for hiding this comment

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

yeah I think that should be sufficient, we'll need to do some mobile screenreader testing and what not just to be sure.

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.

Can't click ModalOverlay to close an open Combobox

4 participants