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

Allow the filter prop of ReferenceArrayField to handle arrays #5871

Closed
srosset81 opened this issue Feb 5, 2021 · 3 comments · Fixed by #5887
Closed

Allow the filter prop of ReferenceArrayField to handle arrays #5871

srosset81 opened this issue Feb 5, 2021 · 3 comments · Fixed by #5887

Comments

@srosset81
Copy link
Contributor

srosset81 commented Feb 5, 2021

Is your feature request related to a problem? Please describe.
The ReferenceArrayField component has a filter prop which allows to filter results client-side. However if the filtered value is an array, the filter does not work because the component does a simple == comparison.
For example if I have a resource with a property foo: ['bar', 'baz'], then using the filter prop { foo: 'bar' } will not return this property because 'bar' != ['bar', 'baz'].

Describe the solution you'd like
Change this line in the useReferenceArrayFieldController to something like this:

const recordValue = get(record, filterName);
return Array.isArray(recordValue) ? recordValue.includes(filterValue) : filterValue == recordValue;

Describe alternatives you've considered
Create our own component, but I think this is a feature others may want.

Additional context
I can do a PR if you think this is a good idea.

@djhi
Copy link
Collaborator

djhi commented Feb 8, 2021

Hi and thanks for the report. Would you mind creating a PR for this?

@srosset81
Copy link
Contributor Author

Done here: #5887

@fzaninotto
Copy link
Member

Fixed by #5887

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants