Skip to content

Commit

Permalink
Merge pull request #95 from aodn/bugfix/5761-fix-search-bug
Browse files Browse the repository at this point in the history
🐛 fix search bar category bug and enter event bug
  • Loading branch information
utas-raymondng authored Jul 22, 2024
2 parents 4d046aa + e2b68b6 commit 38d24b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/common/store/searchReducer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/components/search/InputWithSuggester.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,13 @@ const InputWithSuggester: FC<InputWithSuggesterProps> = ({
const handleKeyDown = (
event: React.KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>
) => {
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<number>(0);
Expand Down

0 comments on commit 38d24b5

Please sign in to comment.