From f011b6c6d8e12d5e21722accaab22d6613358b69 Mon Sep 17 00:00:00 2001 From: MytsV Date: Wed, 9 Oct 2024 18:32:23 +0300 Subject: [PATCH] Allow switching between name and scope inputs via keyboard arrows --- .../features/search/DIDSearchPanel.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/component-library/features/search/DIDSearchPanel.tsx b/src/component-library/features/search/DIDSearchPanel.tsx index f754fd1a7..9c7c096fa 100644 --- a/src/component-library/features/search/DIDSearchPanel.tsx +++ b/src/component-library/features/search/DIDSearchPanel.tsx @@ -96,6 +96,18 @@ export const DIDSearchPanel = (props: SearchPanelProps) => { props.stopStreaming(); }; + const onScopeArrowDown = (event: React.KeyboardEvent) => { + if (event.key === 'ArrowRight') { + nameInputRef.current?.focus(); + } + }; + + const onNameArrowDown = (event: React.KeyboardEvent) => { + if (event.key === 'ArrowLeft') { + scopeInputRef.current?.focus(); + } + }; + return (
@@ -121,6 +133,7 @@ export const DIDSearchPanel = (props: SearchPanelProps) => { setScope(event.target.value); }} onEnterKey={onSearch} + onKeyDown={onScopeArrowDown} /> : { setName(event.target.value); }} onEnterKey={onSearch} + onKeyDown={onNameArrowDown} />