From 03e5ecbc7c8e80edd1cd28f298cef1efeee25a33 Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Wed, 12 Jun 2024 13:55:35 +0200 Subject: [PATCH] Form on search page retains context The result category will no longer be reset to 'repository' when the search query is refined and resubmitted. --- gradle/changelog/enhance_searchpage.yaml | 2 ++ scm-ui/ui-webapp/src/containers/OmniSearch.tsx | 9 +++++---- scm-ui/ui-webapp/src/search/Search.tsx | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 gradle/changelog/enhance_searchpage.yaml diff --git a/gradle/changelog/enhance_searchpage.yaml b/gradle/changelog/enhance_searchpage.yaml new file mode 100644 index 0000000000..1437818726 --- /dev/null +++ b/gradle/changelog/enhance_searchpage.yaml @@ -0,0 +1,2 @@ +- type: changed + description: Search category stays the same when the search query is modified diff --git a/scm-ui/ui-webapp/src/containers/OmniSearch.tsx b/scm-ui/ui-webapp/src/containers/OmniSearch.tsx index 870bb356cd..be4200d2c5 100644 --- a/scm-ui/ui-webapp/src/containers/OmniSearch.tsx +++ b/scm-ui/ui-webapp/src/containers/OmniSearch.tsx @@ -39,6 +39,7 @@ type Props = { shouldClear: boolean; ariaId: string; nextFocusRef: RefObject; + selectedType?: string; }; type GuardProps = Props & { @@ -121,7 +122,7 @@ const useSearchParams = () => { }; }; -const OmniSearch: FC = ({ shouldClear }) => { +const OmniSearch: FC = ({ shouldClear, selectedType = "repository" }) => { const [t] = useTranslation("commons"); const { initialQuery } = useSearchParams(); const [query, setQuery] = useState(shouldClear ? "" : initialQuery); @@ -173,7 +174,7 @@ const OmniSearch: FC = ({ shouldClear }) => { ); } @@ -181,7 +182,7 @@ const OmniSearch: FC = ({ shouldClear }) => { ); hits?.forEach((hit, idx) => { @@ -195,7 +196,7 @@ const OmniSearch: FC = ({ shouldClear }) => { ); }); return newEntries; - }, [context.name, context.namespace, hits, id, query, searchTypes, t]); + }, [context.name, context.namespace, hits, id, query, searchTypes, selectedType, t]); return (
{showHelp ? : null} diff --git a/scm-ui/ui-webapp/src/search/Search.tsx b/scm-ui/ui-webapp/src/search/Search.tsx index 2d7d6b670f..98184b6513 100644 --- a/scm-ui/ui-webapp/src/search/Search.tsx +++ b/scm-ui/ui-webapp/src/search/Search.tsx @@ -158,7 +158,7 @@ const SearchSubTitle: FC = ({ selectedType, queryResult, links }) => {
]} /> - + );