Intent to Prototype: document.advanceFocus() and beforefocus

112 views
Skip to first unread message

Marat Abdullin

unread,
11:31 AM (10 hours ago) 11:31 AM
to blin...@chromium.org

Contact emails

Marat Abdullin mar...@microsoft.com

Explainer

https://open-ui.org/components/beforefocus.explainer

Specification

https://open-ui.org/components/beforefocus.explainer

This is an incubating design, not yet an adopted standard. Proposed HTML
integration:
https://github.com/whatwg/html/issues/13104.

Summary

document.advanceFocus() lets a page move focus using the browser's own Tab
order, with options for direction, starting point, containment and wrapping.
It returns a Promise reporting the outcome. The cancelable
beforefocus event
lets a page stop a focus move before an element receives focus.

Blink component

Blink>HTML>Focus

Web Feature ID

Not assigned; requested in:
https://github.com/web-platform-dx/web-features/issues/4558.

Motivation

Dialogs, keyboard navigation and protection against focus theft often require
apps to reconstruct focus order or redirect focus after it has moved. These
primitives let apps use the browser's navigation instead, including across
shadow DOM and embedded frames.

Initial public proposal

https://github.com/openui/open-ui/issues/1261

Goals for experimentation

No origin trial is proposed. The current work is limited to off-by-default
prototyping and feedback on API ergonomics and safe focus interception.

Requires code in //chrome?

No. The current Chromium prototype does not change files under //chrome.

Tracking bug

https://issues.chromium.org/issues/575489395

Measurement

The Blink WIP prototype adds DocumentAdvanceFocus for method calls and
BeforeFocusEvent for browser-generated event dispatch.
Implementation:
https://chromium-review.googlesource.com/c/chromium/src/+/8612302.
These are prototype use counters, not an assigned Web Feature ID.

Estimated milestones

None proposed; this is an off-by-default prototype, not a shipping request.

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5134711960764416?gate=5156755611975680

Prototype and related work

Chromium implementation: https://chromium-review.googlesource.com/8612302.

In a build containing the Chromium patch, enable FocusNavigation with
--enable-blink-features=FocusNavigation; pages also opt in with:

<meta name="focus-navigation" content="advanceFocus beforefocus">

The Chromium and Firefox prototypes have matching tentative WPTs,
supplemented by native tests.

Blink test review:
https://chromium-review.googlesource.com/c/chromium/src/+/8612302/2.

Gecko test review:
https://phabricator.services.mozilla.com/D335668?id=1414112.

These are browser-prototype review links, not a standalone upstream WPT PR.
A single upstream export remains to be coordinated.

Firefox tracking: https://bugzilla.mozilla.org/show_bug.cgi?id=2084212.
Firefox intent: planned. I will reply here with the dev-platform thread once
it is public.
Firefox implementation:
https://phabricator.services.mozilla.com/D335668.

I welcome feedback on API ergonomics and safe focus interception, particularly
keyboard and assistive-technology behavior. These are contributor-maintained
prototypes, not independent vendor endorsements. Current local testing is on
macOS, not all platforms.

This intent message uses the Chrome Platform Status generated template,
supplemented with prototype details.


Thanks,
Marat Abdullin
Reply all
Reply to author
Forward
0 new messages