Skip to content

Commit

Permalink
fix: avoid changing url when removing filters (#1530)
Browse files Browse the repository at this point in the history
* Makes the Active Tab Key independent from the URL, except for the initial load, where the active tab is set from the url.
*Avoids unnecessarily changing SearchParams: Due to a limitation of the useSearchParams react hook, which uses a memoized value for the URL that becomes stale after selecting a tab, it unexpectedly changes the URL value. Unfortunately there's no way to completely avoid this, so if there's a usageKey url param, the hook setter function will be called and the URL will revert to the stale memoized url.
  • Loading branch information
DanielVZ96 authored Dec 6, 2024
1 parent d2d7532 commit 73490a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/library-authoring/LibraryAuthoringPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const LibraryAuthoringPage = ({ returnToLibrarySelection }: LibraryAuthoringPage
} else if (currentPath && currentPath in ContentType) {
setActiveKey(ContentType[currentPath]);
}
}, [location.pathname]);
}, []);

useEffect(() => {
if (!componentPickerMode) {
Expand Down
4 changes: 3 additions & 1 deletion src/search-manager/SearchManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ export const SearchContextProvider: React.FC<{
setBlockTypesFilter([]);
setTagsFilter([]);
setProblemTypesFilter([]);
setUsageKey('');
if (usageKey !== '') {
setUsageKey('');
}
}, []);

// Initialize a connection to Meilisearch:
Expand Down

0 comments on commit 73490a5

Please sign in to comment.