Skip to content

Commit

Permalink
Start search when user presses enter (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpgmaas authored Jun 23, 2024
1 parent 45d1345 commit c5b0ff6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions frontend/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ export default function Home() {
setResults(sortResults(results, field, direction));
};

const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
handleSearch(
text,
sortField,
sortDirection,
setResults,
setLoading,
setError,
);
}
};

return (
<div className="min-h-screen w-full bg-sky-950 flex flex-col items-center">
<Header />
Expand All @@ -55,6 +69,7 @@ export default function Home() {
className="placeholder-gray-400 w-full h-24 p-2 border border-sky-900 rounded resize-none overflow-auto focus:outline-none focus:ring-2 focus:ring-sky-800 bg-white text-sky-950"
value={text}
onChange={(e) => setText(e.target.value)}
onKeyDown={handleKeyDown}
placeholder="Describe what you are looking for... "
></textarea>
<button
Expand Down

0 comments on commit c5b0ff6

Please sign in to comment.