Skip to content

Commit

Permalink
fix(core): update useTable hook
Browse files Browse the repository at this point in the history
- reset filters and sorters used in tables on URL query clear
  • Loading branch information
arndom committed Oct 6, 2024
1 parent a0e3a26 commit 1c92edc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/core/src/hooks/useTable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,28 @@ export function useTable<
return `${pathname ?? ""}?${stringifyParams ?? ""}`;
};

useEffect(() => {
if (!parsedParams?.params?.filters && !parsedParams?.params?.sorters) {
const resetFilters = setInitialFilters(
preferredPermanentFilters,
defaultFilter ?? [],
);
const resetSorters = setInitialSorters(
preferredPermanentSorters,
defaultSorter ?? [],
);

setFilters(resetFilters);
setSorters(resetSorters);
}
}, [
parsedParams,
preferredPermanentFilters,
defaultFilter,
preferredPermanentSorters,
defaultSorter,
]);

useEffect(() => {
if (search === "") {
setCurrent(defaultCurrent);
Expand Down

0 comments on commit 1c92edc

Please sign in to comment.