From 83d20d44b78c8265d018506457100bbf2bd19783 Mon Sep 17 00:00:00 2001 From: David Mzareulyan Date: Thu, 31 Oct 2024 17:46:01 +0300 Subject: [PATCH] Submit the advanced search form by Enter on text fields --- .../advanced-search-form/advanced-search-form.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/advanced-search-form/advanced-search-form.jsx b/src/components/advanced-search-form/advanced-search-form.jsx index 346a0dd6..52e72537 100644 --- a/src/components/advanced-search-form/advanced-search-form.jsx +++ b/src/components/advanced-search-form/advanced-search-form.jsx @@ -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 ( -
+