Open frivoal opened 6 years ago
could we instead make the properties define local spatial navigation (e.g. between components) while allowing components to determine navigation behavior inside of themselves?
This sounds like the behavior you would want. For instance, you might embed a complex component, like a WYSIWYG editor, into a page. The WYSIWYG editor may implement spatial navigation in a way that's really useful within the confines of the component itself, but perhaps different from how the user wants to navigate the page as a whole.
The Working Group just discussed https://github.com/w3c/csswg-drafts/issues/1910
.
@alice shared this in our IRC chat today. It's a link to the bit of the Shadow DOM spec that describes how focus moves into a shadow root and finds the first focusable element. https://www.w3.org/TR/shadow-dom/#x5.2-focus
The definition of Directional Focus Navigation says (among other things) this:
Making an element focusable, as the spec currently requires, is not useful: if there's no event handler attached to it the element, then focusing it doesn't get you anything. And if If there is, then the element should be made focusable anyway (via
tabindex=0
or what have you), regardless of directional navigation. We mostly landed on that behavior for accidental historical reasons, rather than due to usecases: this was what the Presto implementation happened to do, and sticking with it meant less friction on our way along TR, especially since Presto was no longer updated. However, this kind of rationale is only reasonable if there is no use case either way and we just need to pick something for consistency.But there are use cases arguing the other way, and the behavior suggested by the note is much more useful: when the target isn't focusable, search from there in document order for the first focusable element, and focus that instead. Modern web pages are often built out of components (web components, react components or angular components...), and the top embedding page should be able to treat them as black boxes. Being able to target the top level element of the component, and letting document order (with potential overrides as discussed in https://github.com/w3c/csswg-drafts/issues/1764) deal with the rest would go a long way.
See https://github.com/lgeweb/spatial-navigation/blob/master/explainer.md#current-approach for an example of worry about the current lack of composability (cc @jihyerish ).