React-admin: Filters should reset when selecting a new/same resource from the sidebar

Created on 13 Apr 2018  Â·  6Comments  Â·  Source: marmelab/react-admin

What you were expecting:
When clicking on a resource in the sidebar, any selected filters should revert to their default values, especially since the URL changes to the base for that resource.

What happened instead:
Filters remain applied, although the URL implies there are no filters present. Hence if you reload the page at that point, you get a different set of results.

Steps to reproduce:
In the sample app, goto customers (https://marmelab.com/admin-on-rest-demo/#/customers). Pick Add Filter, then pick Segments and choose any one. Then goto a different resource and come back to customers (or just click customers again). The filter will still be applied (and is correctly shown in the UI), but the URL is back to https://marmelab.com/admin-on-rest-demo/#/customers. Hence if you reload the page or share the link the state will not be the same or reload.

Reproducible in the demo version.

Environment

  • Admin-on-rest version: 1.4.0
  • Last version that did not exhibit the issue (if applicable):
  • React version: 16.2.0
  • Browser: Chromium 65.0.3325.181
  • Stack trace (in case of a JS error):

Most helpful comment

@madecki Do you have a snippet available that removes the filter on route change (from resource click in the sidebar) with a custom saga?

using the cross button close to each filter

Related: https://github.com/marmelab/react-admin/issues/2564

All 6 comments

That's not a bug, that's a featureâ„¢.

We see lists as Excel sheets. When you switch from one sheet to the other, you don't expect the sorting and filtering to reset.

So we want that filtered lists stay filtered, even if users come back to it from the menu. If the user wants to remove filters, they can do it using the cross button close to each filter.

@fzaninotto Is there any possibility to reset them with every route change as it's described above? Some advices?

You should ask this on StackOverflow. In a nutshell, you should be able to do that with a custom saga and the CRUD_CHANGE_LIST_PARAMS action

I believe it's doable using a custom redux middleware.

Wow, I wasn't expecting so quick answer :) great guys, thanks for a tip

@madecki Do you have a snippet available that removes the filter on route change (from resource click in the sidebar) with a custom saga?

using the cross button close to each filter

Related: https://github.com/marmelab/react-admin/issues/2564

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marknelissen picture marknelissen  Â·  3Comments

kikill95 picture kikill95  Â·  3Comments

kopax picture kopax  Â·  3Comments

samanmohamadi picture samanmohamadi  Â·  3Comments

pixelscripter picture pixelscripter  Â·  3Comments