Add a registry model and view for managing keyboard shortcuts.

Review Request #13591 — Created March 1, 2024 and submitted — Latest diff uploaded

Information

Ink
master

Reviewers

Part of Ink's focus on accessibility is formalizing support for keyboard
shortcuts. Components will be able to easily list keyboard shortcuts
that trigger an element, providing both a visual indicator and ARIA
information for screen readers.

Keyboard shortcuts will be registered in the new
KeyboardShortcutRegistry model, which takes a key, modifier flags, and
a callback handler, and registers it for quick access.

A corresponding KeyboardShortcutRegistryView can be attached to an
existing element and a registry model to invoke the handlers when those
keys are pressed.

Once attached, a registry view can be found on any ancestor DOM element
by using KeyboardShortcutRegistryView.findNearestRegistryView.
Similarly, a nearest registry can be found using
findNearestRegistry().. This makes it easy for components to
automatically register with the correct registry.

The plan is to eventually let the view pop up a dialog when ? is
pressed, to show the available keyboard shortcuts. This has been a
long-standing plan for Review Board, and with these new foundational
classes, we'll be able to offer this.

Unit tests pass.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

orig
1
2
3

Commits

First Last Summary ID Author
Add a registry model and view for managing keyboard shortcuts.
Part of Ink's focus on accessibility is formalizing support for keyboard shortcuts. Components will be able to easily list keyboard shortcuts that trigger an element, providing both a visual indicator and ARIA information for screen readers. Keyboard shortcuts will be registered in the new `KeyboardShortcutRegistry` model, which takes a key, modifier flags, and a callback handler, and registers it for quick access. A corresponding `KeyboardShortcutRegistryView` can be attached to an existing element and a registry model to invoke the handlers when those keys are pressed. The plan is to eventually let the view pop up a dialog when `?` is pressed, to show the available keyboard shortcuts. This has been a long-standing plan for Review Board, and with these new foundational classes, we'll be able to offer this.
487ca4c8562f412b6d5b0219e07417b24321987c Christian Hammond
src/ink/js/index.ts
src/ink/js/foundation/index.ts
src/ink/js/foundation/models/index.ts
src/ink/js/foundation/models/keyboardShortcutRegistry.ts
src/ink/js/foundation/models/tests/keyboardShortcutRegistryTests.ts
src/ink/js/foundation/views/index.ts
src/ink/js/foundation/views/keyboardShortcutRegistryView.ts
src/ink/js/foundation/views/tests/keyboardShortcutRegistryViewTests.ts
Loading...