Contrary to your intuition or common sense, the virtual indicator does not follow 1-to-1 with DOM focus. Stupid, I know. When can you see this? Well, it's most apparent when using VDOM and client-side routing, e.g. React and React Router DOM.
Since client-side routing & VDOM doesn't do a hard refresh, the content of the page may visually change, but the AT never fully resets. So if you expect the focus to reset to the beginning of your content, well... sorry, but that ain't how it works (unfortunately). It varies from AT to AT (screw you voiceover 😡), but generally, if the entire page tree changes, the focus will return to the document.body (if you check the document.activeElement). Right, so that's where the focus is, but where's the virtual indicator?? It depends and is not quite deterministic. Sometimes it will jump around the page until it sticks somewhere and sometimes it will try to focus on the element beneath its last position.
The AT virtual indicator, why do?
Contrary to your intuition or common sense, the virtual indicator does not follow 1-to-1 with DOM focus. Stupid, I know. When can you see this? Well, it's most apparent when using VDOM and client-side routing, e.g. React and React Router DOM.
Since client-side routing & VDOM doesn't do a hard refresh, the content of the page may visually change, but the AT never fully resets. So if you expect the focus to reset to the beginning of your content, well... sorry, but that ain't how it works (unfortunately). It varies from AT to AT (screw you voiceover 😡), but generally, if the entire page tree changes, the focus will return to the
document.body
(if you check thedocument.activeElement
). Right, so that's where the focus is, but where's the virtual indicator?? It depends and is not quite deterministic. Sometimes it will jump around the page until it sticks somewhere and sometimes it will try to focus on the element beneath its last position.