From 6409e0ffde851afd013e5751a94397f6240d93be Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 17 Feb 2024 13:46:28 -0700 Subject: [PATCH] Do not need to encode query. Clearing search input when user navigates to dashboard. --- app/src/components/Common.js | 10 ++++++++++ app/src/components/Search.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/components/Common.js b/app/src/components/Common.js index def9e409..33792b7c 100644 --- a/app/src/components/Common.js +++ b/app/src/components/Common.js @@ -405,6 +405,16 @@ const useClearableInput = (searchStr, onChange, onClear, onSubmit, size = 'small const [value, setValue] = useState(searchStr || ''); const [submitted, setSubmitted] = useState(false); + React.useEffect(() => { + // Search was changed above. + if (searchStr !== value) { + setValue(searchStr); + } + if (!searchStr) { + setValue(''); + } + }, [searchStr, value]); + const handleChange = (e) => { if (e) { e.preventDefault(); diff --git a/app/src/components/Search.js b/app/src/components/Search.js index 20554bc1..da959c40 100644 --- a/app/src/components/Search.js +++ b/app/src/components/Search.js @@ -165,7 +165,7 @@ export function useSearchSuggestions(defaultSearchStr, defaultTagNames) { title: newSuggestions.fileGroups.toString(), type: 'files', // Add search query onto current location. - location: getLocationStr({q: encodeURIComponent(searchStr)}, '/search') + location: getLocationStr({q: searchStr}, '/search'), } ] };