react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Custom List Actions Crashes When There are no filters

Open djhi opened this issue 2 years ago • 2 comments

What you were expecting: Being able to set a custom list actions component even when there are no filters

What happened instead: The page crashes with the following error:

FilterButton requires filters prop to be set

Steps to reproduce: Follow the documentation for custom actions: https://marmelab.com/react-admin/List.html#actions

Related code: https://codesandbox.io/s/restless-mountain-frq98x?file=/src/posts/PostList.tsx

I update the PostList so that it has a very simple custom actions component and no filters.

  • React-admin version: 4.1.2
  • Last version that did not exhibit the issue (if applicable):
  • React version:
  • Browser:
  • Stack trace (in case of a JS error):

djhi avatar Jun 09 '22 08:06 djhi

For my understanding I would like you to explain why you consider this behavior as a bug?

If neither the FilterButton component nor the List component have filter props, why shouldn't we display an error?

arimet avatar Aug 18 '22 15:08 arimet

So this might just be a documentation issue but I still think we should ensure adding the <FilterButton> in your custom actions shouldn't crash if you haven't provided any filter yet.

djhi avatar Aug 22 '22 07:08 djhi