Skip to content

Commit f011b6c

Browse files
MytsVmaany
authored andcommitted
Allow switching between name and scope inputs via keyboard arrows
1 parent ed3ef43 commit f011b6c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/component-library/features/search/DIDSearchPanel.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ export const DIDSearchPanel = (props: SearchPanelProps) => {
9696
props.stopStreaming();
9797
};
9898

99+
const onScopeArrowDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
100+
if (event.key === 'ArrowRight') {
101+
nameInputRef.current?.focus();
102+
}
103+
};
104+
105+
const onNameArrowDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
106+
if (event.key === 'ArrowLeft') {
107+
scopeInputRef.current?.focus();
108+
}
109+
};
110+
99111
return (
100112
<div className="flex flex-col space-y-2 w-full md:items-start md:flex-row md:space-y-0 md:space-x-2">
101113
<div className="flex flex-col grow sm:flex-row space-y-2 sm:space-x-2 sm:space-y-0">
@@ -121,6 +133,7 @@ export const DIDSearchPanel = (props: SearchPanelProps) => {
121133
setScope(event.target.value);
122134
}}
123135
onEnterKey={onSearch}
136+
onKeyDown={onScopeArrowDown}
124137
/>
125138
<span className="text-neutral-900 dark:text-neutral-100 font-bold">:</span>
126139
<Input
@@ -131,6 +144,7 @@ export const DIDSearchPanel = (props: SearchPanelProps) => {
131144
setName(event.target.value);
132145
}}
133146
onEnterKey={onSearch}
147+
onKeyDown={onNameArrowDown}
134148
/>
135149
</div>
136150
</div>

0 commit comments

Comments
 (0)