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

improvement: a11y: arrow-key navigation for messages #4294

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Oct 30, 2024

2024-10-30-0C6LIUUYry.mp4

Based on #4291

Closes #2141

Basically what this commit comes down to:

  1. Apply useRovingTabindex for message items
  2. Set tabindex="-1" on all the interactive items
    inside every message that is currently not the active one,
    so that they do no have tab stops.

TODO:

  • Address the TODOs in the code
  • Manage what's gonna be the initially active message,
    because initially they're all active, so
    tabbing to the messages list from the top selects
    the first rendered one as the active one.
    WIP: refactor: useRovingTabindex to utilize IDs #4292
    could help with this.
    This is also not great for performance: changing tabindex
    on a bunch of messages makes them all re-render.
    And otherwise, we probably want to update which one is
    the active one as new messages arrive.
  • Some jumpToMessage calls ought to focus the message. For example, when jumping to a message through a click on a quote, or a webxdc info message. But not all jumpToMessage should change focus. For example, receiving a new message shouldn't do it. This probably requires that we add a focus parameter to jumpToMessage. Perhaps even 2 parameters: whether to set the message as the active one in the messages list (without focusing it), and whether to focus it.
    This can be done in further MRs.
  • The interactive items with onClick must be actual semantic
    <button>s.
    See improvement: improve a11y #4210
    for reference.

@WofWca WofWca added accessibility enhancement New feature or request labels Oct 30, 2024
@WofWca WofWca force-pushed the wofwca/roving-tabindex-for-messages branch from 21857cf to 901f71c Compare October 30, 2024 16:18
@WofWca WofWca changed the title WIP: improvement: a11y: arrow-key navigation for messages improvement: a11y: arrow-key navigation for messages Oct 30, 2024
@WofWca WofWca force-pushed the wofwca/roving-tabindex-for-messages branch 3 times, most recently from 6db255c to 1d35935 Compare October 31, 2024 10:50
Implements the "roving tabindex" approach:
https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex.

Supersedes #4211.

This improves things, but the UX as a whole is not great yet:
- The tab order is such that the chat list does not
  immediately follow the search field,
  so you have to tab through the other navbar items
  before you get to the chat list.
  Same for going back from the chat list to the search bar.
- The initially "active" element is just the first chat item,
  and not the currently selected chat.
- Since the chat list is "virtualized", the currently active element
  might get removed from DOM when the user scrolls,
  thus we lose track of the item that was last selected.

Related: #2784
This is needed so that it can utilize `RovingTabindexProvider`
context.
It's harder to forget to set it this way.
Closes #2141

Basically what this commit comes down to:
1. Apply `useRovingTabindex` for message items
2. Set `tabindex="-1"` on all the interactive items
    inside every message that is currently not the active one,
    so that they do no have tab stops.
@WofWca WofWca force-pushed the wofwca/roving-tabindex-for-messages branch from 1d35935 to fe5b337 Compare November 3, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accessibility: Make the individual chat list more accessible.
1 participant