Skip to content

Commit

Permalink
Submit the advanced search form by Enter on text fields
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmz committed Oct 31, 2024
1 parent 242e9d0 commit 83d20d4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/advanced-search-form/advanced-search-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,19 @@ export function AdvancedSearchForm() {
browserHistory.push(`/search?q=${encodeURIComponent(resultingQuery)}`),
);

const onKeyDown = useEvent((e) => {
if (
e.code === 'Enter' &&
e.target.matches('input[type="text"], input[type="date"], input[type="search"]')
) {
e.preventDefault();
onSearch();
}
});

return (
<filtersContext.Provider value={ctxValue}>
<div className={style.form}>
<div className={style.form} onKeyDown={onKeyDown}>
<Section title="What to search">
<div className={style.searchInputBox}>
<input
Expand Down

0 comments on commit 83d20d4

Please sign in to comment.