| Summary: | Safari moves focus to first focusable element inside an element with role="dialog" and aria-modal="true" when added to the DOM | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Alex Moore <matthew.garrath.thomas> | ||||||
| Component: | Accessibility | Assignee: | Nobody <webkit-unassigned> | ||||||
| Status: | NEW --- | ||||||||
| Severity: | Normal | CC: | andresg_22, ntim, tyler_w, webkit-bug-importer | ||||||
| Priority: | P2 | Keywords: | InRadar | ||||||
| Version: | Safari 15 | ||||||||
| Hardware: | All | ||||||||
| OS: | iOS 15 | ||||||||
| Attachments: |
|
||||||||
|
Description
Alex Moore
2022-02-14 03:51:58 PST
Thanks for the bug report! It's implemented this way due to this language in the aria-modal spec (though WebKit's autofocus behavior will currently also apply to <dialog>): https://w3c.github.io/aria/#aria-modal > When a modal element is displayed, assistive technologies SHOULD navigate to the element unless focus has explicitly been set elsewhere. Technically, with that wording it should be VoiceOver (and other assistive technologies) doing this automatic focusing, but WebKit does this itself for now. I do understand how this could be annoying when other browsers don't do this. And it would definitely be a bug if this autofocus behavior is trouncing explicit focus via JS or otherwise. It seems that the focus isn't moved anymore in either Safari TP or iOS 15.5 beta, so something must have changed the behaviour, as it now matches the other browsers. It might be due to another bug though, as Safari TP seems to struggle with the page, and it crashes and then needs to reload it as soon as you try to inspect it. See the attached screenshot. Created attachment 459109 [details]
Crash message after inspect
Crash message after inspect
Edit: Only changed in Safari TP, not iOS. The crash you're experiencing will be fixed by https://bugs.webkit.org/show_bug.cgi?id=240365 (Infinite recursion caused by call to accessibilityIsIgnored in the midst of AccessibilityObject::ignoredFromModalPresence). With this change in place, I can confirm that the latest `main` WebKit does still autofocus with your testcase. |