Skip to content
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

fix(core): reset table filters and sorters on current page re-navigate via side-nav #6389

Closed

Conversation

arndom
Copy link
Contributor

@arndom arndom commented Oct 6, 2024

  • Update useTable hook to handle case where a user navigates to current page by clicking side-nav link intending to reset the filters and sorters.

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

In a table, apply some filters/sorters then click the menu item in the sidebar, the URL should reset filters and sorters to the default but it doesn't.

This can be previewed at https://example.admin.refine.dev/orders

What is the new behavior?

The above has been resolved. It resets the query params for filters and sorters back to their defaults.

fixes #6300

Notes for reviewers

arndom added 2 commits October 6, 2024 21:59
- reset filters and sorters used in tables on URL query clear
@arndom arndom requested a review from a team as a code owner October 6, 2024 21:16
Copy link

changeset-bot bot commented Oct 6, 2024

🦋 Changeset detected

Latest commit: 089edd2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@arndom arndom changed the title Fix/core/list url params fix/(core): reset table filters and sorters on current page re-navigate via side-nav Oct 6, 2024
@arndom arndom changed the title fix/(core): reset table filters and sorters on current page re-navigate via side-nav fix(core): reset table filters and sorters on current page re-navigate via side-nav Oct 6, 2024
Copy link
Member

@BatuhanW BatuhanW left a comment

Choose a reason for hiding this comment

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

Hey @arndom thanks for the PR, please make sure to add tests for the behavior.

.changeset/spicy-flowers-allow.md Outdated Show resolved Hide resolved
@BatuhanW BatuhanW changed the base branch from master to releases/october October 7, 2024 12:23
Copy link
Member

@aliemir aliemir left a comment

Choose a reason for hiding this comment

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

Hey @arndom thank you for your effort! 🙏 I've left a comment in the issue (#6300 (comment)) about the implementation we're looking for.

While your changes will work for the reported case, it won't cover other cases such as changing the query params without using the useTable hook.

Let us know if you can work on the changes described in the comment 🙏

@arndom
Copy link
Contributor Author

arndom commented Oct 12, 2024

@aliemir Sure, it's best to finish what I started properly...though I may need some guidance as I'm still fresh on the codebase

@aliemir aliemir deleted the branch refinedev:releases/december-2024 October 14, 2024 12:54
@aliemir aliemir closed this Oct 14, 2024
@aliemir aliemir reopened this Oct 14, 2024
@aliemir aliemir changed the base branch from releases/october to master October 14, 2024 12:57
@BatuhanW
Copy link
Member

Hey @arndom are you gonna be able to continue on this PR? Please let us know if you need help with a specific issue. We'd be happy to guide you through.

@arndom
Copy link
Contributor Author

arndom commented Oct 28, 2024

@BatuhanW I still plan to, I just haven't had the time recently due to my work schedule. Some help on the approach to solving this would be great.

My current thought process: Since syncWithLocation defined in refine context is used by multiple implementations for params syncing, a change in all those may provide a fix (possibly a shared function). I am unsure about its efficiency or if there are better solutions as I haven't spent that much time in the repo.

@arndom arndom force-pushed the fix/core/list-url-params branch from 31011aa to 4864ec7 Compare November 24, 2024 10:23
@arndom arndom force-pushed the fix/core/list-url-params branch from 4864ec7 to 2810644 Compare November 24, 2024 10:37
@alicanerdurmaz alicanerdurmaz changed the base branch from master to releases/december-2024 November 25, 2024 07:55
@arndom
Copy link
Contributor Author

arndom commented Dec 1, 2024

@aliemir I believe the recent commits take into consideration the updating of filters and sorters; URL state -> internal state and vice versa.

@aliemir
Copy link
Member

aliemir commented Dec 3, 2024

Hey @arndom, I've tried on my local but looks like the effect is exceeding the max depth and even if I ignore it, it starts looping when I have a change in filters 🤔 I'll try to look again to see what went wrong and at least provide tips to get it back on track 🙏

@arndom
Copy link
Contributor Author

arndom commented Dec 3, 2024

Sorry about that, seems I did not test properly, I'll go through it again and resolve the issues

- prevent watched url filters from being early triggered by change to url by internal filter
@alicanerdurmaz alicanerdurmaz force-pushed the releases/december-2024 branch 2 times, most recently from 7b46480 to 20d1c42 Compare December 9, 2024 13:09
@BatuhanW
Copy link
Member

Hey @arndom feel free to re-open it when your changes are complete.

@BatuhanW BatuhanW closed this Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] not clear filters and sorters when clicking menu item
3 participants