-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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 <FilterForm>
ignores key
prop on children
#9588
Conversation
Can you please add a unit test showing the bug, and explain the use case for this? #9587 gives a good use case for datagrid fields, but I fail to understand in which case you need the same for filters. |
If you have a FK that links to 2 different resources, you could have 2 ReferenceInputs in order to filter based on one linked resource or the other (you might even want a plain NumberInput or similar to set the value directly). Another case might be something like a combobox, radio buttons or similar to select from a number of favourite/recent options, while also having a text or slider or similar to be able to filter on other values. |
I put a test in, but realised the key is not rendered, so I don't think there's anything I can actually assert with the test. Not sure how you handle warnings, but I have |
I'm still not convinced by the use cases you list. It may be something you want to do in your app, but I don't think it's something we want to support with the react-admin basic filters. I'll wait for the feedback of other contributors. Your test doesn't seem to do any useful assertion. Also, I understand that the filter already works in your use case, but simply logs a warning in the console. Am I right? |
I mean, it's not like I'm asking you to explicitly support these complex features. I just want to be able to specify the key on components explicitly, as I've done everywhere else in the app. It seems odd to me that it throws away the key that already exists on the component, and the fix for that is 2 words.
That is what I said. The only thing I can test, as far as I can tell, is that the warning doesn't occur. |
Just to expand on that, this is the warning. It's pretty clear that the behaviour is bad, may cause issues today, and may become a error in future:
|
I've updated the test so it's explicitly testing something now.
A specific example of this is filtering on age range. You might have one input that provides a 2-point slider to select a range. Then a second input that provides a drop-down of pre-selected age ranges for convenience ("Adult (18+)", "Child (3-17)", "Infant (<=2)"). |
Your test passes even without the fix in FilterForm... It's not testing the right code. |
Sorry, I've been super busy. If the test is still passing, then I can only imagine the tests are already doing something with warnings and managing to ignore them? |
Not that I know of. |
OK, it's an error, not a warning. Test works properly now. FYI, there are plenty of other errors and warnings getting logged in the other tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
<FilterForm>
ignores key
prop on children
Tangentially related to #9587, if 2 inputs are used in filters with the same source then they end up with duplicate keys even when those components already provide their own unique keys.