Skip to content

Commit

Permalink
Allow switching between name and scope inputs via keyboard arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
MytsV committed Oct 9, 2024
1 parent 56aedf1 commit 3354102
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/component-library/features/search/DIDSearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ export const DIDSearchPanel = (props: SearchPanelProps) => {
props.stopStreaming();
};

const onScopeArrowDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'ArrowRight') {
nameInputRef.current?.focus();
}
};

const onNameArrowDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'ArrowLeft') {
scopeInputRef.current?.focus();
}
};

return (
<div className="flex flex-col space-y-2 w-full md:items-start md:flex-row md:space-y-0 md:space-x-2">
<div className="flex flex-col grow sm:flex-row space-y-2 sm:space-x-2 sm:space-y-0">
Expand All @@ -121,6 +133,7 @@ export const DIDSearchPanel = (props: SearchPanelProps) => {
setScope(event.target.value);
}}
onEnterKey={onSearch}
onKeyDown={onScopeArrowDown}
/>
<span className="text-neutral-900 dark:text-neutral-100 font-bold">:</span>
<Input
Expand All @@ -131,6 +144,7 @@ export const DIDSearchPanel = (props: SearchPanelProps) => {
setName(event.target.value);
}}
onEnterKey={onSearch}
onKeyDown={onNameArrowDown}
/>
</div>
</div>
Expand Down

0 comments on commit 3354102

Please sign in to comment.