Fix/search bar search disappearing after submit (#728)
* Correctly update search string on location change
Regression introduced with aab3e25031
* Remove unnecessary usage of "useSessionStorage"
This did not add anything and made no sense
This commit is contained in:
@@ -13,7 +13,6 @@ import { useQueryParam, StringParam } from 'use-query-params';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { SearchTextField } from '@/components/atoms/SearchTextField.tsx';
|
||||
import { useSessionStorage } from '@/util/useStorage.tsx';
|
||||
|
||||
interface IProps {
|
||||
isClosable?: boolean;
|
||||
@@ -33,15 +32,13 @@ export const AppbarSearch: React.FunctionComponent<IProps> = (props) => {
|
||||
|
||||
const [searchString, setSearchString] = useState(query ?? '');
|
||||
|
||||
const [locationQuery, setLocationQuery] = useSessionStorage<string | null>(`appbarsearch-location-${location.key}`);
|
||||
if (prevLocationKey !== location.key) {
|
||||
setPrevLocationKey(location.key);
|
||||
setLocationQuery(query);
|
||||
setSearchString(locationQuery ?? '');
|
||||
setIsSearchOpen(!isClosable || !!locationQuery);
|
||||
setSearchString(query ?? '');
|
||||
setIsSearchOpen(!isClosable || !!query);
|
||||
}
|
||||
|
||||
const isOpen = isSearchOpen || !!locationQuery;
|
||||
const isOpen = isSearchOpen || !!query;
|
||||
|
||||
const updateSearchOpenState = (open: boolean) => {
|
||||
if (!isClosable) {
|
||||
|
||||
Reference in New Issue
Block a user