w3ctag / design-reviews

W3C specs and API reviews
Creative Commons Zero v1.0 Universal
318 stars 55 forks source link

Review the HTML spec's treatment of focus #468

Open alice opened 4 years ago

alice commented 4 years ago

There has been work recently, e.g. https://github.com/whatwg/html/pull/4754, to give the HTML spec a more consistent handling of focus.

We should check what the status of that work is, whether it is being tracked in a single place, and review the work as a complete set once it's done.

alice commented 4 years ago

From @rakina, some starting points:

https://blog.whatwg.org/focusing-on-focus https://github.com/whatwg/html/issues/4607

alice commented 4 years ago

See also: https://github.com/w3c/webcomponents/issues/762

alice commented 4 years ago

See also: https://github.com/whatwg/html/issues/5326

alice commented 3 years ago

Looking at this in our virtual face to face just now, I have some relatively unstructured thoughts:

If we were adding keyboards as a new usage mode on the web today (as a highly unlikely counterfactual), we would suggest writing an explainer outlining the user needs, the platform constraints, and how the proposed design meets those user needs. It seems like the work done on focus in the HTML spec has only outlined the (no longer proposed, but factual) design, without explaining how it fits together, documenting any regrettable decisions, or any user needs which should be taken into account when designing additions to the system.

In particular, the decision to have :focus match on unfocusable shadow hosts when the "actual" focused element is inside a shadow root seems to have made a priority of constituencies trade-off in the dispreferred direction: in order to avoid potentially revealing the existence of a shadow root (theoretical purity, or at best convenience for developers), it shows a focus highlight by default on the shadow host, creating a confusing experience for users.

A much older feature, tabindex=-1, also has some regrettable aspects:

I began some work to explore the needs which tabindex=-1 is attempting to address in https://github.com/WICG/webcomponents/issues/762#issuecomment-692416176, but it would be good to have a full-fledged "focus on the web" explainer which explains in terms of user needs, rather than simply explaining the state of the spec right now.

hober commented 1 year ago

@alice wrote:

but it would be good to have a full-fledged "focus on the web" explainer which explains in terms of user needs, rather than simply explaining the state of the spec right now.

Do you think the TAG should be trying to find someone in the community (@rakina, maybe, or someone from WAI) to write such an explainer?

atanassov commented 1 year ago

@travisleithead (nudge :)) could also help us make progress on this given his experience in both DOM and accessibility space. Or help find someone who could offer some time for this.