Skip to content

Commit

Permalink
Issue #393 - Fix autocomplete focus on backspace event
Browse files Browse the repository at this point in the history
  • Loading branch information
delrifai committed Dec 16, 2024
1 parent 616d729 commit 93125e4
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions components/ui/AutoCompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,11 @@ const AutocompleteInput: React.FC<AutocompleteInputProps> = ({
inputRef.current?.focus();
linkResult ? "" : closeSearchBar();
}
}
};

useEffect(() => {
const keyDownEvent = (event: KeyboardEvent) => {
if (event.key === "Backspace") {
setInputFocus(true); // Reopen the suggestions on backspace
}
};

document.addEventListener("keydown", keyDownEvent);
return () => {
document.removeEventListener("keydown", keyDownEvent);
};
}, []);

}
};
// Ensure the selected result is visible in the scrollable container
useEffect(() => {
if (selectedResultRef.current) {
Expand Down

0 comments on commit 93125e4

Please sign in to comment.