From 7312f87130eec52e39ab5185934cb5eb0fdfad64 Mon Sep 17 00:00:00 2001 From: William Glas Date: Wed, 7 Sep 2022 13:32:49 -0400 Subject: [PATCH 1/2] Fix a bug in the useMnemonics hook to make it compatible with textareas --- .changeset/mean-bees-ring.md | 5 +++++ src/__tests__/hooks/useMnemonics.test.tsx | 14 ++++++++++++++ src/hooks/useMnemonics.ts | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/mean-bees-ring.md diff --git a/.changeset/mean-bees-ring.md b/.changeset/mean-bees-ring.md new file mode 100644 index 00000000000..965a8d3d3d1 --- /dev/null +++ b/.changeset/mean-bees-ring.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +useMnemonics hook ignores keydown events from textarea elements diff --git a/src/__tests__/hooks/useMnemonics.test.tsx b/src/__tests__/hooks/useMnemonics.test.tsx index 5bbb9e58b38..beb26f2858d 100644 --- a/src/__tests__/hooks/useMnemonics.test.tsx +++ b/src/__tests__/hooks/useMnemonics.test.tsx @@ -5,10 +5,12 @@ import {useMnemonics} from '../../hooks' const Fixture = ({ onSelect = () => null, hasInput = false, + hasTextarea = false, refNotAttached = false }: { onSelect?: (event: React.KeyboardEvent) => void hasInput?: boolean + hasTextarea?: boolean refNotAttached?: boolean }) => { const containerRef = React.createRef() @@ -19,6 +21,7 @@ const Fixture = ({
{/* eslint-disable-next-line jsx-a11y/no-autofocus */} {hasInput && } + {hasTextarea &&