Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[focusgroup] Should focusgroup direction follow the DOM order or the visual order? #1044

Open
gfellerph opened this issue Apr 26, 2024 · 4 comments
Assignees

Comments

@gfellerph
Copy link
Collaborator

gfellerph commented Apr 26, 2024

In the current version of the focusgroup explainer, the direction can be restricted to inline and block directions. However, there are many ways to alter the visual order of elements that can be combined in many different ways. A particularly cursed example would be this focusgroup maze on codepen.

The focusgroup maze - five numbered buttons rearranged with CSS to create a confusing tab order

In this example, the tab key moves focus through the buttons in DOM order. Because of the many directional changes applied in CSS, tabbing through the buttons seems to move the focus in random order (positions 4, 3, 5, 2, 1).

While this is the expected behavior of the tab key, it might be problematic for the arrow keys when pressing the right arrow key moves the focus visually to the left.

Which order should focusgroup follow when identifying the next candidate to focus?

  1. Should focusgroup always respect the visual order for selecting the next element to focus? (What would this mean for assistive technology?)
  2. Should focusgroup only support certain properties, e.g. writing-mode but not others like transform. If yes, what properties should be supported and which should not be supported?
  3. Should focusgroup move focus in DOM order (respecting limitations on up/down and left/right arrow keys based on inline or block direction)?

There are most likely other things to consider and more possible answers to the question.

@gfellerph gfellerph changed the title [focusgroup] Should focusgroup direction follow the tab order or the visual order? [focusgroup] Should focusgroup direction follow the DOM order or the visual order? Apr 26, 2024
@lukewarlow
Copy link
Collaborator

https://drafts.csswg.org/css-display-4/#reading-order-items - this feels relevant here

@travisleithead
Copy link
Collaborator

Interesting. From @lukewarlow's link, this line in the "Design Considerations" section seemed particularly relevant:

Linear navigation, focus sequencing order, and screen-reader order should always match, because there are users who use them together.

Would that imply that arrow key navigation would also jump around (like TAB) in the above cursed example because it would also be following DOM order (despite the weird visual appearance)? If a screen reader's perception of the content would follow the same DOM order logic, that would make the most sense to me from an accessibility standpoint...

@gfellerph
Copy link
Collaborator Author

That makes a lot of sense (and will make the implementation easier, I guess).

@dizhang168
Copy link

I am currently prototyping the changes for CSS reading-flow in chromium, in FocusController. Because the focusgroup prototype is currently under FocusgroupController, it is currently opted out of the feature. Note that this feature is specifically for elements with display: grid and display: flex, which is a different concept from the Grid for this feature (which is more for tables, from what I have seen).

Now, if a focusgroup container is also a reading flow container and we want it to follow the visual order, we would need to update the advance logic in FocusgroupController. I think that should be doable. If interested, I would encourage you to take a look at the HTML standard proposal (whatwg/html#10407) and other active conversations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants