From e2b68b6800d1c0d25b36e3e87ed3f6d218d1cdfe Mon Sep 17 00:00:00 2001 From: Lyn Long Date: Mon, 22 Jul 2024 10:54:04 +1000 Subject: [PATCH] :bug: fix search bar category bug and enter event bug --- src/components/common/store/searchReducer.tsx | 7 +++++-- src/components/search/InputWithSuggester.tsx | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/common/store/searchReducer.tsx b/src/components/common/store/searchReducer.tsx index 128f3730..0d30bd8f 100644 --- a/src/components/common/store/searchReducer.tsx +++ b/src/components/common/store/searchReducer.tsx @@ -303,9 +303,12 @@ const createSearchParamFrom = (i: ParameterState): SearchParameters => { p.filter = appendFilter(p.filter, f(i.polygon)); } - if (i.categories) { + if (i.categories && i.categories.length > 0) { const f = cqlDefaultFilters.get("CATEGORIES_IN") as CategoriesIn; - p.filter = appendFilter(p.filter, f(i.categories)); + const categoryFilter = f(i.categories); + if (categoryFilter) { + p.filter = appendFilter(p.filter, categoryFilter); + } } return p; diff --git a/src/components/search/InputWithSuggester.tsx b/src/components/search/InputWithSuggester.tsx index d529d0e8..ee5898bf 100644 --- a/src/components/search/InputWithSuggester.tsx +++ b/src/components/search/InputWithSuggester.tsx @@ -240,10 +240,13 @@ const InputWithSuggester: FC = ({ const handleKeyDown = ( event: React.KeyboardEvent ) => { - if (event.key === "Enter") { + if (event.key === "Enter" && open === true) { setOpen(false); + handleEnterPressed(event, false); + } + if (event.key === "Enter" && open === false) { + handleEnterPressed(event, false); } - handleEnterPressed(event, open); }; const [searchFieldWidth, setSearchFieldWidth] = useState(0);