Bug 211934

Summary: AX: aria-modal="true" autofocuses the first focusable child when inside an iframe
Product: WebKit Reporter: Devon Govett <govett>
Component: AccessibilityAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: cfleizach, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 13   
Hardware: All   
OS: All   

Description Devon Govett 2020-05-14 16:53:48 PDT
When rendering a dialog with `aria-modal="true"` inside an iframe, Safari auto focuses the first focusable child of the dialog, even though the dialog itself is focused by JavaScript. No other browsers seem to have this behavior.

Reproduction: https://b3gkn.csb.app - the close button will be auto focused in Safari, after a flash of focus being on the dialog itself.
Opening the iframe page directly does not cause the issue: https://b3gkn.csb.app/iframe.html.

Source code for the reproduction: https://codesandbox.io/s/objective-currying-b3gkn?file=/index.html

I wouldn't expect the browser to auto focus anything with `aria-modal="true"` (AFAIK no other browsers do this), but if it does, it should respect the element that the developer focuses with JavaScript.
Comment 1 Radar WebKit Bug Importer 2020-05-14 16:53:58 PDT
<rdar://problem/63249533>
Comment 2 chris fleizach 2021-02-01 12:05:58 PST
(In reply to Radar WebKit Bug Importer from comment #1)
> <rdar://problem/63249533>

on iOS, VoiceOver can't focus on a "group" like a dialog. it needs to focus on one of the flat elements in the list of elements to navigate. I think in the absence of further guidance it picks an element to land on.