feat: Make ComboBox optionally modal#10314
Conversation
| * | ||
| * @default true | ||
| */ | ||
| isNonModal?: boolean; |
There was a problem hiding this comment.
I think the name isModal is more clear, but I used isNonModal to align with Popover's isNonModal prop.
| isReadOnly, | ||
| isDisabled | ||
| isDisabled, | ||
| isNonModal = true |
There was a problem hiding this comment.
true preserves existing behavior.
| import {useOverlay} from '../../src/overlays/useOverlay'; | ||
|
|
||
| export function ComboBox(props: AriaComboBoxProps<any>): JSX.Element { | ||
| export function ComboBox(props: AriaComboBoxProps<any> & {isNonModal?: boolean}): JSX.Element { |
There was a problem hiding this comment.
I didn't expose the modal behavior on Spectrum's ComboBox, so we need this type intersection here.
|
Hey, thanks for the PR. So we intentionally use aria-hidden instead of inert here so that users can |
|
@snowystinger thanks for the context! Are you open to a change that applies a |
I'm not sure what this would look like. Either it involves a lot of re-renders or it's a lot of searching the dom for inputs and anything else that could trigger it and then the cleanup. Would it be possible to limit what you run AXE on? if you have a combobox open, you just need to run it on the input and the popover, nothing else actually matters |
|
The logic to add/remove the
I didn't notice any significant performance difference between applying just profiling-dataAfter.json
We can choose to turn off a rule entirely, or we can configure a CSS selector of elements to consider/ignore. We prefer not turning off rules unless absolutely necessary. We might be able to use a CSS selector that ignores any elements with |
|
would Would it be ok to only do it during dev, and not in production builds? |

Closes #4937
This MR optionally makes
ComboBoxmodal by exposing anisNonModalattribute on bothuseComboBoxand RAC'sComboBox. It does not implement that behavior on Spectrum'sComboBox.Existing behavior (i.e. hiding outside elements with
aria-hiddenwhile the popover is open) is preserved as the default to respect the portal strategy outlined here. WhenisNonModal={true}, outside elements receiveinertto prevent interactions whenever the popover is open.✅ Pull Request Checklist:
📝 Test Instructions:
useComboBox
Modal (new behavior)
ptags above and below the ComboBox haveinertattributea. The popover closes
b. The browser does not navigate to the link
c. The
ptags no longer have theinertattributeNon-Modal (existing behavior)
ptags above and below the ComboBox havearia-hiddenattributea. The popover closes
b. The browser navigates to the link
ComboBox (React Aria Components)
Modal (new behavior)
ptags above and below the ComboBox haveinertattributea. The popover closes
b. The browser does not navigate to the link
c. The
ptags no longer have theinertattributeNon-Modal (existing behavior)
ptags above and below the ComboBox havearia-hiddenattributea. The popover closes
b. The browser navigates to the link
🧢 Your Project:
Screenshots
Modal (new behavior)
Non-Modal (existing behavior)