Accessibility: Support disabling global character keyboard shortcuts
Created by: umpox
Description
As part of WCAG 2.1, we need to provide a mechanism to remap or turn off character key shortcuts.
This PR:
- Makes it possible to disable our global character key shortcuts
- Refactors our shortcuts to use a
useKeyboardShortcut
hook so we no longer:- Pass
keyboardShortcuts
down as props in lots of places - Directly import and use keyboard shortcuts.
- Pass
Note I noticed a few areas where we can improve our keyboard shortcuts, this is not relevant to this PR, but should be done for future work: (These are captured in this issue: https://github.com/sourcegraph/sourcegraph/issues/39218)
- We currently rely on a single set of keyboard shortcuts everywhere. This might burn us in the future (e.g. if we use a conflicting shortcut). We could modify our existing approach to pass a set of shortcuts into our
ShortcutContext
, this would let us vary them depending on the environment.- We currently rely on an NPM package
@slimsag/react-shortcuts
that doesn't appear to have a public repository. We should bring this in-house, as it is already a fork of a Shopify package.- We have a series of shortcuts that do not use this method for keyboard shortcuts. We should update these.
Test plan
Tested locally:
- Using keyboard shortcuts
- Disabling character key shortcuts
App preview:
Check out the client app preview documentation to learn more.