Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export function useUrlSearchState(): {
const sub = urlStateStorage.current
?.change$<SearchState>(SLO_LIST_SEARCH_URL_STORAGE_KEY)
.subscribe((newSearchState) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An empty/cleared search state resets to DEFAULT_STATE.

if (newSearchState) {
setState(newSearchState);
}
// When URL has no search params, newSearchState will be null/undefined
// In that case, reset to DEFAULT_STATE
setState(newSearchState ?? DEFAULT_STATE);
});

setState(
Expand All @@ -88,9 +88,7 @@ export function useUrlSearchState(): {
const updatedState = { ...state, page: 0, ...newState };
setState(() => updatedState);

urlStateStorage.current?.set(SLO_LIST_SEARCH_URL_STORAGE_KEY, updatedState, {
replace: true,
});
urlStateStorage.current?.set(SLO_LIST_SEARCH_URL_STORAGE_KEY, updatedState);

// Discard search itself from session storage. Keep only view preferences
sessionStorage.current?.set(
Expand Down