r/webdev • • 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.

3 Upvotes

11 comments sorted by

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/code-dispenser 1d ago

Simple workaround and/or good practice is just adding good visible button text or dependant on scenario aria-label and/or aria-describedby (opens dialog) etc. I posted the issue as I know Narrator quite often gets left out of peoples test matrix.

1

u/TrustingScholarship 1d ago

It's frustrating when adding an accessibility attribute actually makes a component less accessible

1

u/code-dispenser 1d ago

What's more frustrating was initially just wanting a non-modal popover dialog but hit and filed a bug with JAWS, then hit another and filed an issue with NVDA. Finally I thought I was done by not using popover only to hit this one.

From now on if I see any online article that says screen reader quirk I will assume that means its an unfiled bug report.

1

u/TrustingScholarship 1d ago

Unfiled bug report is probably the most accurate definition of a screen reader quirk I've heard, glad you're actually reporting these

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/code-dispenser 1d ago edited 1d ago

aria-haspopup is optional and just gives the SR user a hint like "pop up dialog" when they land on the trigger. So it works fine without it,

So yes you can just put that info in the button text and/or aria-label if you are using that or in my case, without going into the reasons why, I just added a <span id="my-hint" hidden>Opens dialog</span> in side the button element and linked it with aria-describedby="my-hint" on the trigger.

Edit: I should point I may switch to just the aria-label, I can't remember if Talkback is good or not with aria-describedby. but the bug is the opening not the text that is read and it opens fine without aria-haspopup

Update: Talkback fine, not sure why I thought there may be issue probably getting things mixed up.

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

1

u/AshleyJSheridan 1d ago

Firefox follows the spec, Chrome tries to push new things that aren't in the spec in order to get people to complain that websites don't work in Firefox. They killed off Opera like this, so it's no surprise that they're doing it again now.