Bug 253957

Summary: [iOS VoiceOver] document.activeElement cannot point to a button that has attribute aria-haspopup
Product: WebKit Reporter: Aaron Hakala <aaron.hakala>
Component: AccessibilityAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: andresg_22, ntim, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: iPhone / iPad   
OS: iOS 16   

Description Aaron Hakala 2023-03-15 05:30:37 PDT
# Summary

When using iOS VoiceOver with Safari/Chrome the `document.activeElement` is not pointing to a button that has the attribute `aria-haspopup` instead it returns the `body` element. Removing this attribute causes the the `document.activeElement` to point to the button.

I guess this issue might be a symptom of some other focus handling logic.

# Example situation

1. A button opens a modal/dialog. This element is recorded by using the `document.activeElement`.
2. Modal captures focus.
3. When modal is closed the focus is returned to the element that opened the modal.

If the button has the attribute `aria-haspopup` the `document.activeElement` points to `body` instead of the `button`.

Example codepen: https://codepen.io/aaronkala/pen/wvEmeZL

# Expected behaviour

The `document.activeElement` points to the `button` even if it contains the `aria-haspopup` attribute.
Comment 1 Radar WebKit Bug Importer 2023-03-15 05:30:48 PDT
<rdar://problem/106751475>