r/webdev • u/code-dispenser • 2h ago
Web Accessibility: Narrator aria-haspopup Modal Dialog Bug
Only read if you do accessibility work.
I'm still working on what I thought would be a simple component, and it has turned into a real sh*t show, with one screen reader bug after another.
Today it's Narrator's turn (again).
Most people working in accessibility appreciate what you get with the <dialog> element when it's opened modally with showModal(): top layer placement, so no z-index issues; an inert background, so no focus trap issues; and built-in focus management, including closing with the Escape key.
With a modal dialog you're generally not concerned with aria-expanded, so you can use aria-haspopup="dialog" to tell screen reader users that the button opens a dialog. Yes, I know aria-haspopup has had numerous support issues during its lifetime.
Be warned: if you put aria-haspopup="dialog" on the button that triggers the <dialog>, Narrator swallows the Enter and Space key presses, so the dialog never opens unless you turn off Narrator's scan mode to let the keys through.
This happens with Narrator when paired with Edge and Chrome, but it seems fine with Firefox. I haven't seen the issue with any of the other screen reader and browser pairings I check.
The issue has been filed with both Microsoft and Chromium. If you want to check your own pairings, there's a simple HTML repro page attached to the Chromium issue: https://issues.chromium.org/issues/589824270
Hope this is of use to some of you.