Commit e09ff8c6 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Remove unneeded `normalizeKeyName` utility use

`normalizeKeyName` provided normalization of `event.key` names for
key* events for legacy browsers. We no longer support those legacy
browsers (IE11, Legacy Edge), so this utility is no longer necessary.
parent a5ece40a
import { normalizeKeyName } from '@hypothesis/frontend-shared';
import { useEffect } from 'preact/hooks'; import { useEffect } from 'preact/hooks';
/** /**
...@@ -55,7 +53,7 @@ export function matchShortcut(event, shortcut) { ...@@ -55,7 +53,7 @@ export function matchShortcut(event, shortcut) {
return ( return (
actualModifiers === requiredModifiers && actualModifiers === requiredModifiers &&
normalizeKeyName(event.key).toLowerCase() === requiredKey event.key.toLowerCase() === requiredKey
); );
} }
......
import { normalizeKeyName } from '@hypothesis/frontend-shared';
import { useCallback, useState } from 'preact/hooks'; import { useCallback, useState } from 'preact/hooks';
import { withServices } from '../../service-context'; import { withServices } from '../../service-context';
...@@ -165,7 +164,7 @@ function AnnotationEditor({ ...@@ -165,7 +164,7 @@ function AnnotationEditor({
// Allow saving of annotation by pressing CMD/CTRL-Enter // Allow saving of annotation by pressing CMD/CTRL-Enter
/** @param {KeyboardEvent} event */ /** @param {KeyboardEvent} event */
const onKeyDown = event => { const onKeyDown = event => {
const key = normalizeKeyName(event.key); const key = event.key;
if (isEmpty) { if (isEmpty) {
return; return;
} }
......
...@@ -3,7 +3,6 @@ import { ...@@ -3,7 +3,6 @@ import {
IconButton, IconButton,
LabeledButton, LabeledButton,
Link, Link,
normalizeKeyName,
} from '@hypothesis/frontend-shared'; } from '@hypothesis/frontend-shared';
import classnames from 'classnames'; import classnames from 'classnames';
import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
...@@ -394,7 +393,7 @@ export default function MarkdownEditor({ ...@@ -394,7 +393,7 @@ export default function MarkdownEditor({
} }
for (let [command, key] of Object.entries(SHORTCUT_KEYS)) { for (let [command, key] of Object.entries(SHORTCUT_KEYS)) {
if (key === normalizeKeyName(event.key)) { if (key === event.key) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
handleCommand(/** @type {Command} */ (command)); handleCommand(/** @type {Command} */ (command));
......
import classnames from 'classnames'; import classnames from 'classnames';
import { import { Icon, useElementShouldClose } from '@hypothesis/frontend-shared';
Icon,
normalizeKeyName,
useElementShouldClose,
} from '@hypothesis/frontend-shared';
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
import MenuArrow from './MenuArrow'; import MenuArrow from './MenuArrow';
...@@ -137,7 +133,7 @@ export default function Menu({ ...@@ -137,7 +133,7 @@ export default function Menu({
// It should also close if the user presses a key which activates menu items. // It should also close if the user presses a key which activates menu items.
/** @param {KeyboardEvent} event */ /** @param {KeyboardEvent} event */
const handleMenuKeyDown = event => { const handleMenuKeyDown = event => {
const key = normalizeKeyName(event.key); const key = event.key;
if (key === 'Enter' || key === ' ') { if (key === 'Enter' || key === ' ') {
// The browser will not open the link if the link element is removed // The browser will not open the link if the link element is removed
// from within the keypress event that triggers it. Add a little // from within the keypress event that triggers it. Add a little
......
import classnames from 'classnames'; import classnames from 'classnames';
import { Icon, normalizeKeyName } from '@hypothesis/frontend-shared'; import { Icon } from '@hypothesis/frontend-shared';
import { useEffect, useRef } from 'preact/hooks'; import { useEffect, useRef } from 'preact/hooks';
import MenuKeyboardNavigation from './MenuKeyboardNavigation'; import MenuKeyboardNavigation from './MenuKeyboardNavigation';
...@@ -161,7 +161,7 @@ export default function MenuItem({ ...@@ -161,7 +161,7 @@ export default function MenuItem({
/** @param {KeyboardEvent} event */ /** @param {KeyboardEvent} event */
const onKeyDown = event => { const onKeyDown = event => {
switch (normalizeKeyName(event.key)) { switch (event.key) {
case 'ArrowRight': case 'ArrowRight':
if (onToggleSubmenu) { if (onToggleSubmenu) {
event.stopPropagation(); event.stopPropagation();
......
import { normalizeKeyName } from '@hypothesis/frontend-shared';
import { useEffect, useRef } from 'preact/hooks'; import { useEffect, useRef } from 'preact/hooks';
/** @param {HTMLElement} element */ /** @param {HTMLElement} element */
...@@ -62,7 +61,7 @@ export default function MenuKeyboardNavigation({ ...@@ -62,7 +61,7 @@ export default function MenuKeyboardNavigation({
let handled = false; let handled = false;
switch (normalizeKeyName(event.key)) { switch (event.key) {
case 'ArrowLeft': case 'ArrowLeft':
case 'Escape': case 'Escape':
if (closeMenu) { if (closeMenu) {
......
import { import { useElementShouldClose, TextInput } from '@hypothesis/frontend-shared';
normalizeKeyName,
useElementShouldClose,
TextInput,
} from '@hypothesis/frontend-shared';
import { useRef, useState } from 'preact/hooks'; import { useRef, useState } from 'preact/hooks';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
...@@ -172,7 +168,7 @@ function TagEditor({ ...@@ -172,7 +168,7 @@ function TagEditor({
* @param {KeyboardEvent} e * @param {KeyboardEvent} e
*/ */
const handleKeyDown = e => { const handleKeyDown = e => {
switch (normalizeKeyName(e.key)) { switch (e.key) {
case 'ArrowUp': case 'ArrowUp':
// Select the previous item in the suggestion list // Select the previous item in the suggestion list
changeSelectedItem(-1); changeSelectedItem(-1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment