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? |
|
In our case, we need the attribute in production builds as we run our tests in production/staging environments (both of which are non- |
|
When you run axe, I'm assuming through Cypress, can you assert that there is a Combobox open? Or, I assume you know one is open because you opened it via the test. Then, when you run axe, you could use the configuration: If I'm missing the mark, maybe you can explain more about how you're running this. |
|
Thanks for that suggestion! For these specific checks, we're running Axe Watcher for Playwright Test in order to generate results for Axe Developer Hub. Those a11y checks run automatically on every Playwright test, so we can't control when the assertion runs. And I don't believe we can configure the rule to ignore certain selectors (I tried). We can only:
It would be great if we can exclude In any case, I appreciate your ideas to get our tests passing! |

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)