Bug 263069 - AX: VoiceOver on iOS moves focus away, even when HTMLElement.focus() is called on an element
Summary: AX: VoiceOver on iOS moves focus away, even when HTMLElement.focus() is calle...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Safari 17
Hardware: iPhone / iPad iOS 17
: P2 Normal
Assignee: Nobody
URL: https://f76xpz.csb.app/
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-10-12 05:27 PDT by Domantas Petrauskas
Modified: 2024-05-02 11:05 PDT (History)
3 users (show)

See Also:


Attachments
Screen recording of focus bug reproduction (2.41 MB, video/quicktime)
2023-10-12 05:27 PDT, Domantas Petrauskas
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Domantas Petrauskas 2023-10-12 05:27:55 PDT
Created attachment 468186 [details]
Screen recording of focus bug reproduction

When navigating in a multi-step UI, where currently focused element disappears when navigating between steps, the VoiceOver cursor & browser focus jumps to the "closest" element after a brief moment, even when forcing focus on another element via HTMLElement.focus().

Steps to reproduce:
1. Open https://f76xpz.csb.app/ on iOS with VoiceOver. Open console to view logs.
2. Click on "Next step" button"
3. Observe focus being set on "Previous step" button and then jumping to "Save and continue" a few milliseconds later.

Expected result: Focus should get set and remain on "Previous step" button

Actual result: Focus gets set on "Previous step", but then jumps on "Save and continue".

I'm assuming VoiceOver always needs to have a focus on an element, so when the currently focused element disappears, VoiceOver focuses the element "closest" to the position where the focused element was. However, this happens after a brief delay, so even if you set the focus manually on another element, VoiceOver overrides it.

It is important to respect the HTMLElement.focus() in order to comply with WCAG 2.1 Standard Focus Order success criterion: https://www.w3.org/TR/WCAG21/#focus-order

The issue is not reproducible on Mac VoiceOver. Setting tabIndex on "Previous step" button does not change the behaviour in any way.
Comment 1 Radar WebKit Bug Importer 2023-10-12 05:28:05 PDT
<rdar://problem/116858667>
Comment 2 marc.solomon 2024-05-02 11:05:34 PDT
This issue may be related to Bug 273635 - AX: VoiceOver cursor does not sync with browser focus after closing dialog when interactive element is positioned behind it.