fix: avoid changing url when removing filters (#1530)

* 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.
This commit is contained in:
Daniel Valenzuela
2024-12-06 18:24:04 -03:00
committed by GitHub
parent d2d753203f
commit 73490a5741
2 changed files with 4 additions and 2 deletions

View File

@@ -148,7 +148,7 @@ const LibraryAuthoringPage = ({ returnToLibrarySelection }: LibraryAuthoringPage
} else if (currentPath && currentPath in ContentType) {
setActiveKey(ContentType[currentPath]);
}
}, [location.pathname]);
}, []);
useEffect(() => {
if (!componentPickerMode) {

View File

@@ -147,7 +147,9 @@ export const SearchContextProvider: React.FC<{
setBlockTypesFilter([]);
setTagsFilter([]);
setProblemTypesFilter([]);
setUsageKey('');
if (usageKey !== '') {
setUsageKey('');
}
}, []);
// Initialize a connection to Meilisearch: