Make everything use the KeyBindingManager (#7907)

This commit is contained in:
Šimon Brandner 2022-02-28 17:05:52 +01:00 committed by GitHub
parent 5f8441216c
commit df591ee835
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 529 additions and 277 deletions

View file

@ -19,9 +19,10 @@ import React from 'react';
import classNames from "classnames";
import { _t } from "../../../languageHandler";
import { Key } from "../../../Keyboard";
import { CategoryKey, ICategory } from "./Category";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
interface IProps {
categories: ICategory[];
@ -57,18 +58,20 @@ class Header extends React.PureComponent<IProps> {
// https://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-1/tabs.html
private onKeyDown = (ev: React.KeyboardEvent) => {
let handled = true;
switch (ev.key) {
case Key.ARROW_LEFT:
const action = getKeyBindingsManager().getAccessibilityAction(ev);
switch (action) {
case KeyBindingAction.ArrowLeft:
this.changeCategoryRelative(-1);
break;
case Key.ARROW_RIGHT:
case KeyBindingAction.ArrowRight:
this.changeCategoryRelative(1);
break;
case Key.HOME:
case KeyBindingAction.Home:
this.changeCategoryAbsolute(0);
break;
case Key.END:
case KeyBindingAction.End:
this.changeCategoryAbsolute(this.props.categories.length - 1, -1);
break;
default: