From fa7b55c19f3e50edd3133d98a2103dc355291ec9 Mon Sep 17 00:00:00 2001 From: Paul Clue <67766160+Paul-Clue@users.noreply.github.com> Date: Tue, 14 May 2024 08:54:35 -0500 Subject: [PATCH 1/3] Add type-ahead to assign tester dropdown --- .../TestQueue/AssignTesterDropdown/index.jsx | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/client/components/TestQueue/AssignTesterDropdown/index.jsx b/client/components/TestQueue/AssignTesterDropdown/index.jsx index a21e5b226..44da30c0d 100644 --- a/client/components/TestQueue/AssignTesterDropdown/index.jsx +++ b/client/components/TestQueue/AssignTesterDropdown/index.jsx @@ -113,9 +113,33 @@ const AssignTesterDropdown = ({ const clearAriaLiveRegion = () => { setAlertMessage(''); }; + + const handleKeyDown = event => { + const { key } = event; + if (key.match(/[a-z]/)) { + const container = event.target.closest('[role=menu]'); + const matchingMenuItem = Array.from(container.children).find( + menuItem => { + return menuItem.innerText + .trim() + .toLowerCase() + .startsWith(key); + } + ); + + if (matchingMenuItem) { + matchingMenuItem.focus(); + } + } + }; + return ( - + Date: Thu, 16 May 2024 09:55:13 -0500 Subject: [PATCH 2/3] Fix regex to account for more characters --- client/components/TestQueue/AssignTesterDropdown/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/TestQueue/AssignTesterDropdown/index.jsx b/client/components/TestQueue/AssignTesterDropdown/index.jsx index 44da30c0d..6f0851205 100644 --- a/client/components/TestQueue/AssignTesterDropdown/index.jsx +++ b/client/components/TestQueue/AssignTesterDropdown/index.jsx @@ -116,7 +116,7 @@ const AssignTesterDropdown = ({ const handleKeyDown = event => { const { key } = event; - if (key.match(/[a-z]/)) { + if (key.match(/[0-9a-zA-Z]/)) { const container = event.target.closest('[role=menu]'); const matchingMenuItem = Array.from(container.children).find( menuItem => { From 2b76d296e1f370f6649e41d9b0d27880f1ff093c Mon Sep 17 00:00:00 2001 From: Paul Clue <67766160+Paul-Clue@users.noreply.github.com> Date: Thu, 16 May 2024 16:24:21 -0500 Subject: [PATCH 3/3] Make key lower case --- client/components/TestQueue/AssignTesterDropdown/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/TestQueue/AssignTesterDropdown/index.jsx b/client/components/TestQueue/AssignTesterDropdown/index.jsx index 6f0851205..738dd3e3f 100644 --- a/client/components/TestQueue/AssignTesterDropdown/index.jsx +++ b/client/components/TestQueue/AssignTesterDropdown/index.jsx @@ -123,7 +123,7 @@ const AssignTesterDropdown = ({ return menuItem.innerText .trim() .toLowerCase() - .startsWith(key); + .startsWith(key.toLowerCase()); } );