Skip to content

Commit

Permalink
feat: key down enter to trigger search
Browse files Browse the repository at this point in the history
  • Loading branch information
ydcjeff committed Dec 21, 2024
1 parent 74a8c63 commit a7e10e9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/SearchPageJumbotron.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function SearchPageJumbotron() {
});
};

const { q } = query;
const { q = '' } = query;
useEffect(() => {
textareaRef.current.value = q;
}, [q]);
Expand All @@ -116,6 +116,13 @@ function SearchPageJumbotron() {
name="search"
className={classes.input}
minRows={1}
onKeyDown={(e) => {

Check failure on line 119 in components/SearchPageJumbotron.js

View workflow job for this annotation

GitHub Actions / install-and-test

Replace `(e)` with `e`
// enter to trigger search, so disable default line breaking
if (e.key == 'Enter') {
e.preventDefault();
e.target.form.requestSubmit();
}
}}
/>
<button type="submit" className={classes.submit}>
<SearchIcon />
Expand Down

0 comments on commit a7e10e9

Please sign in to comment.