markteekman / accessible-astro-components

A set of Accessible, easy to use, Front-end UI Components for Astro.

Home Page:https://accessible-astro.netlify.app/accessible-components/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modal: dynamically change `aria-hidden` based on modal state

tinymachine opened this issue · comments

Closed modals don't have aria-hidden set to false, so screen readers (like VoiceOver on macOS and iOS) will still read the contents of closed modals. This should probably be defaulted to true, and changed to false in the openModal() method, and reset to true in closeModal().

Good find @tinymachine, thank you! I'll add it to the list 🙂

@tinymachine tested it myself and read into it a little more but it should work fine as it is! The modal has it's visibility at hidden and that should be enough: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden.

Thanks for explaining, @markteekman! That behavior makes perfect sense, and works correctly for me on your Modal demo page. Weirdly, I'm experiencing an issue where embedded Vimeo videos in modals are being read by VoiceOver on iOS 15.4.1 even when the modals are closed (i.e. visibility: hidden), but adding aria-hidden="true" to the modal element fixes it. Not sure if a bug in my code or maybe in Safari/VoiceOver? I'll troubleshoot and let you know if I sort it out. Thanks again!

@tinymachine it got me thinking, could it have anything to do with the embedded Vimeo video being an iframe? And thus it being handled differently as a child of a parent with visibility: hidden?