Replies: 1 comment
|
I have the same need, where i want to set an initial value on page load (which might be empty or not), but where the user can then empty it later which isn't possible with default value alone |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
In my app we have certain filters that, in the first render, we automatically apply to the user. However, we want the user to clear the filter without reapplying the default value.
Context:
The user loads the page and sees a list of TASKS. This tasks are by default (for us would be on the first render) being filtered by tasks NOT DONE. However, we need the user to be able to clear this filter and see all TASKS (NOT DONE, IN PROGRESS & DONE), but in nuqs when setting to null and the state has a default value, it puts back that default.
We found two work arounds:
Change the functionality to make the user explicitly have to select the TASKS he wants to see as: NOT DONE, IN PROGRESS & DONE. And not have a "Clear Filter" but have a "Select All" button.
Something like this:
Since we have more filters and we are handling them in useQueryStates . We have a button to "reset filters" that should handle them as bulk. Our nuqs hook that handles this currently:
All reactions