Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Refactor ContextMenu to use RovingTabIndex (more consistent keyboard navigation accessibility) #7353

Merged
merged 34 commits into from
Dec 17, 2021

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Dec 14, 2021

Refactor ContextMenu to use RovingTabIndex to make the keyboard navigation accessibility (a11y) more consistent across Element.

With RovingTabIndex, the page has different regions available to navigate focus by Tab/Shift + Tab (or whatever screen reader jumping mechanism) and then navigate each region by Arrow keys or Home/End.

Split off from #7339

Testing strategy

Search for <IconizedContextMenu\b, <ContextMenu\b useContextMenu and createMenu

(this list isn't exhaustive but covers the variety/range of context menus and skips some of same simple ones)

  • UserMenu (make sure can still navigate with custom user status messages)
  • MessageActionBar
  • ReactionsRow
  • RoomTile -> renderGeneralMenu
  • RoomTile -> renderNotificationsMenu
  • RoomSubList (the settings ... on each room list heading for sorting stuff)
  • RoomListHeader (the + next to the "Rooms" heading)
  • ThreadPanelHeader "My threads" vs "All threads" (accessed via the top bar, not a thread in the timeline)
  • NetworkDropdown in the explore rooms modal
  • ❔ Spaces QuickSettings (under "Meta Spaces" feature flag, at bottom of Spaces panel)
  • SpaceCreateMenu
  • WidgetContextMenu (/addwidget https://something, open the room info right panel, under the "Widgets" section, hover your widget, open the ... menu)
  • CallContextMenu (start a 1:1 call (has to be answered) to see the ... button labelled "More")
  • DialpadContextMenu (edit src/components/views/voip/CallView/CallViewButtons.tsx#L216 for it to always show, then make a call and look for the dialpad icon button)
  • Stickerpicker

Dev notes

Screen recordings:

TODO

  • Apply RovingTabIndex changes to
    • MenuItem
    • MenuItemCheckbox
    • MenuItemRadio
    • StyledMenuItemCheckbox
    • StyledMenuItemRadio

This change is marked as an internal change (Task), so will not be included in the changelog.

Preview: https://61bb82159f265c080eed2b5d--matrix-react-sdk.netlify.app
⚠️ Do you trust the author of this PR? Maybe this build will steal your keys or give you malware. Exercise caution. Use test accounts.

@MadLittleMods MadLittleMods requested a review from a team as a code owner December 14, 2021 03:45
@MadLittleMods MadLittleMods marked this pull request as draft December 14, 2021 03:45
@MadLittleMods MadLittleMods removed the request for review from a team December 14, 2021 03:45
@MadLittleMods MadLittleMods added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Dec 14, 2021
@MadLittleMods MadLittleMods requested review from t3chguy and removed request for t3chguy December 15, 2021 14:06
…rom the sort change

See #7353 (comment)

Previously, the ContextMenu would only update and render if shouldComponentUpdate
said it should. This excludes the options mutated by the ContextMenu. We forceUpdate
for the other things in the ContextMenu.

Previously, the ContextMenu only rendered properly when it also changed the sort
of the rooms in the list which triggered a render as well.
@@ -25,7 +25,7 @@ import { Key } from "../../Keyboard";
import { Writeable } from "../../@types/common";
Copy link
Contributor Author

@MadLittleMods MadLittleMods Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing strategy:

Everything appears to work now. Just a few that weren't keyboard accessible before and still aren't which we can tackle in later PR's as desired.

  • UserMenu (make sure can still navigate with custom user status messages)
  • MessageActionBar
  • ReactionsRow
    • The reaction picker does a lot of it's own thing but everything seems in order to how it worked before
  • RoomTile -> renderGeneralMenu
  • RoomTile -> renderNotificationsMenu
  • RoomSubList (the settings ... on each room list heading for sorting stuff)
  • RoomListHeader (the + next to the "Rooms" heading)
  • ThreadPanelHeader "My threads" vs "All threads" (accessed via the top bar, not a thread in the timeline)
  • NetworkDropdown in the explore rooms modal
  • ✅ Spaces QuickSettings (under feature flag, at bottom of Spaces panel)
  • SpaceCreateMenu
  • WidgetContextMenu (/addwidget https://something, open the room info right panel, under the "Widgets" section, hover your widget, open the ... menu)
    • Since it only displays on hover, can't get to it via keyboard but the ContextMenu options works fine once it's open
  • CallContextMenu (start a 1:1 call (has to be answered) to see the ... button labelled "More")
  • DialpadContextMenu (edit src/components/views/voip/CallView/CallViewButtons.tsx#L216 for it to always show, then make a call and look for the dialpad icon button)
    • Was not keyboard accessible before
  • Stickerpicker
    • Was not keyboard accessible before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Stickerpicker isn't owned by Element-Web either, its an iframe

@MadLittleMods MadLittleMods changed the title Refactor ContextMenu to use RovingTabIndex Refactor ContextMenu to use RovingTabIndex (more consistent keyboard navigation accessibility) Dec 16, 2021
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@MadLittleMods MadLittleMods merged commit 9289c0c into develop Dec 17, 2021
@MadLittleMods MadLittleMods deleted the madlittlemods/roving-tab-index-context-menu branch December 17, 2021 17:08
@MadLittleMods
Copy link
Contributor Author

Thanks for the review @t3chguy 🐗

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants