-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aria-hidden error #517
Comments
this happens for me too, and it happens even with mouse click on the trigger |
Same here. It causes a bit of accessibility issue. |
Same here, the focus is behind the drawer instead of inside it. |
Same here, any hints in order to make the error disappear? |
Same issue for me. This is caused by the
Alright, my workaround was only moving the problem. This is a really annoying issue, and I don't understand how we can hook into the radix Dialog to avoid the whole DOM becoming "aria-hidden". Live ExampleFrom the docs, open the "non-modal" drawer and see all DOM elements getting "aria-hidden": https://vaul.emilkowal.ski/other#non-modal NoteThis issue doesn't exist with Radix dialog alone. It doesn't add |
Building upon the fix from alexdemers in #497, here is the hacky hook I'm using in my project to remove the unwanted aria-hidden: /**
@param active (Optional) If the Drawer is rendered conditionally, pass a boolean to trigger the fix when needed
*/
export const useFixVaulDrawer = (active = true) => {
useLayoutEffect(() => {
if (!active) return;
const listener = (e: FocusEvent) => {
e.stopImmediatePropagation();
};
document.addEventListener("focusin", listener);
document.addEventListener("focusout", listener);
window.requestAnimationFrame(() => {
// radix also adds a "data-aria-hidden" attribute, so we select the element based on this
const allHiddenNodes = document.querySelectorAll("[data-aria-hidden]");
allHiddenNodes.forEach((node) => {
if (!(node instanceof HTMLElement)) return;
node.removeAttribute("data-aria-hidden");
node.removeAttribute("aria-hidden");
});
});
return () => {
document.removeEventListener("focusin", listener);
document.removeEventListener("focusout", listener);
};
}, [active]);
}; |
Looks like you can add I admittedly haven't done extensive testing on real devices, but I personally think the expected default behaviour of a component like this is to grab and trap focus on open. I'm also inclined to trust the Radix dev's decision to hide the rest of the page to screen readers when using this as a modal. Therefor, unless there's a good reason I'm not aware of, I think autoFocus's default should be changed to true, or even forced to true if modal = true. At the very least the API reference should be updated to include this. @NicoToff I'd say the poor non-modal behaviour is a separate issue to this. The problem there is that setting modal={false} on Drawer.Root doesn't forward this property to Radix's Dialog.Root here, which would prevent the aria-hidden stuff. I haven't combed through those linked issues but I can imagine there's a lot of other problems with this use case because of this. |
Hi there,
Minor bug report. Version: v1.1.0
It seems that keyboard navigation trigger errors when using Vaul drawers.
Steps to reproduce:
This happens with both
asChild
and having a button under it and without it, this should be enough to reproduce it:Also notice that it requires a few taps on Tab key in order to get the focus out of the trigger button that is currently aria-hidden and to the drawer and then inside the drawer elements.
The text was updated successfully, but these errors were encountered: