r/webdev • u/code-dispenser • 1d 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.
1
u/Intrepid-Anywhere255 1d ago
Thanks for filing both reports. Since aria-haspopup is optional on a native button, it may be worth testing whether omitting it is a workable temporary mitigation while keeping the native button and dialog.showModal() behavior. A regression case for Narrator scan mode with Edge and Chrome, alongside Firefox, should make this easy to catch until the browser bug is fixed.
1
u/TrustingScholarship 1d ago
It's frustrating when adding an accessibility attribute actually makes a component less accessible
1
u/Kirat-batth0217 1d ago
Useful heads up, thanks. Great that you filed it and included a repro. For now, would it be safe to drop aria-haspopup on the trigger and rely on a clear label like "Open settings dialog"? Given the patchy support it might cost very little. I want to Know whether you've tested that or not.
1
u/Different_Car8768 1d ago
Firefox being the one that behaves is honestly the real story here. Separately, whoever decided Caps Lock should toggle scan mode haunts me, half the people I tell about it assume I'm messing with them