Skip to content

Commit 3cc9e4d

Browse files
committed
fix(search): improve arrow key navigation in DID search panel
- Arrow keys now move cursor within input field - Only switch between fields when cursor is at edge position - Right arrow switches from scope to name when at end of text - Left arrow switches from name to scope when at beginning
1 parent 165357c commit 3cc9e4d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,26 @@ export const DIDSearchPanel = (props: SearchPanelProps) => {
242242

243243
const onScopeArrowDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
244244
if (event.key === 'ArrowRight') {
245-
nameInputRef.current?.focus();
245+
const input = event.currentTarget;
246+
const cursorPosition = input.selectionStart;
247+
const textLength = input.value.length;
248+
249+
// Only switch to name input if cursor is at the end
250+
if (cursorPosition === textLength) {
251+
nameInputRef.current?.focus();
252+
}
246253
}
247254
};
248255

249256
const onNameArrowDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
250257
if (event.key === 'ArrowLeft') {
251-
scopeInputRef.current?.focus();
258+
const input = event.currentTarget;
259+
const cursorPosition = input.selectionStart;
260+
261+
// Only switch to scope input if cursor is at the beginning
262+
if (cursorPosition === 0) {
263+
scopeInputRef.current?.focus();
264+
}
252265
}
253266
};
254267

0 commit comments

Comments
 (0)