Skip to content

Conversation

@AndrewBrough
Copy link
Contributor

Closes #476

Problem

Bit of a complex one; aria-hidden wasn't being set when using useDialog or using diallogRef.showModal(). On top of this, testing the modal was difficult because aria-hidden was blocking finding the dialog.

Solution

I added useAriaHidden that handles a working order of operations to set aria-hidden and opening the modal without triggering the warning. I learned that aria-hidden needs to be set BEFORE calling showModal, else there's a race condition and the warning could still show up. Instead, I'm handling it by setting state which updates aria-hidden, then a useEffect that listens to that state change when then calls showModal or close. Finally, there's an event listener for close/cancel events that then sets aria-hidden to false.

Notes

If we don't want to solve this here, I think documentation explaining that explicit state handling of aria-hidden is required during implementation would be a good alternative. Or... maybe just remove this and only support the open prop, since that works well and fighting this is clearly not fun.

Anyway, the fix:

Screen.Recording.2025-07-30.at.1.46.16.AM-compressed.mp4

Note the lack of aria-hidden console warnings.

@netlify
Copy link

netlify bot commented Jul 30, 2025

👷 Deploy Preview for react-daisyui processing.

Name Link
🔨 Latest commit 6dade66
🔍 Latest deploy log https://app.netlify.com/projects/react-daisyui/deploys/6889be10e5c49a000843765a

1 similar comment
@netlify
Copy link

netlify bot commented Jul 30, 2025

👷 Deploy Preview for react-daisyui processing.

Name Link
🔨 Latest commit 6dade66
🔍 Latest deploy log https://app.netlify.com/projects/react-daisyui/deploys/6889be10e5c49a000843765a

@netlify
Copy link

netlify bot commented Jul 30, 2025

Deploy Preview for react-daisyui ready!

Name Link
🔨 Latest commit 6dade66
🔍 Latest deploy log https://app.netlify.com/projects/react-daisyui/deploys/6889be10e5c49a000843765a
😎 Deploy Preview https://deploy-preview-480--react-daisyui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modal: accessibility warning, aria-hidden

1 participant