Do not need to encode query. Clearing search input when user navigates to dashboard.

This commit is contained in:
Roland 2024-02-17 13:46:28 -07:00
parent 47b9d6618c
commit 6409e0ffde
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 11 additions and 1 deletions

View file

@ -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();

View file

@ -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'),
}
]
};