Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow switching between name and scope inputs via keyboard arrows #494

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading