-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] not clear filters and sorters when clicking menu item #6300
Comments
Hey @dfang, thanks for reporting the issue. I will look into this and let you know when I find a solution. |
@alicanerdurmaz Can I work on this |
Hey @arndom sure. Assigning to you. |
Hello @BatuhanW While attempting to resolve this issue, I discovered this bug is present even in new refine projects. I checked multiple examples as well and it's the same thing. Eventually, I found that the issue is coming from the How do I go about running the |
I want to clarify the issue here and propose a small workaround. Refine's
We've discussed some changes and refactors about this feature with the team before but it wasn't prioritized. We don't want this issue to be resolved partially and only work for some use cases such as only clearing it when query params are emptied. We'd be happy help if anyone wants to work on a proper implementation with two-way binding 🙏 For now, as a workaround a small effect can be added to the page to check for the changes in the query params and reflect those. Check the example below: const { params } = useParsed();
const { setFilters, setSorters } = useTable();
React.useEffect(() => {
// actual implementation might be different and slightly more complex depending on the use case.
if (!params.filters) setFilters([], "replace");
if (!params.sorters) setSorters([]);
}, [params]); |
Ah ok, having the query changes affect wherever synching is done is a better solution. Where do I start though? From what I can see the This is off the top of my head but does that mean changes would have to be made wherever params synching is needed? Or are there more efficient solutions your team has discussed? |
hey @aliemir I finally had some time to work on this. My approach is to use the params from We can then compare the "new params" and the current params from the internal, if there is a match do nothing, otherwise rebuild internal state with the new query params. Possibly something like this in the const current_sorters = differenceWith(
sorters,
preferredPermanentSorters,
isEqual,
);
const final_sorters = differenceWith(
parsedParams.params.sorter,
current_sorters ,
isEqual,
); For the other implementations that depend on the |
Describe the bug
In a table, apply some filters then click the menu item in left side bar, the url should reset filters and sorters (only apply default ones)
Steps To Reproduce
Expected behavior
reset the filters
Packages
Additional Context
No response
The text was updated successfully, but these errors were encountered: