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

[RFR] Add allowDuplicates for AutocompleteArrayInput #4026

Conversation

alanpoulain
Copy link
Contributor

Following #2912 and fixes #2311.

In React-admin 3, it's not possible to have duplicated values anymore for the AutocompleteArrayInput. However it could be useful to allow this behavior in some cases.

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the related documentation (in docs/Inputs.md)?

Also, you say this follows #2912, but I understand it replaces it, am I right?

@@ -169,15 +174,15 @@ export const getSuggestionsFactory = ({
// ignore the filter to show more choices
suggestions = removeAlreadySelectedSuggestions(
choices,
selectedItem,
allowDuplicates ? null : selectedItem,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if allowDuplicates is true, removeAlreadySelectedSuggestions() returns the input unchanged, so I'd prefer that you test it it's true on lone 175 and avoid calling removeAlreadySelectedSuggestions altogether in that case.

@alanpoulain alanpoulain force-pushed the autocomplete-array-input-allow-duplicates branch from d5da818 to f41214a Compare November 22, 2019 18:20
@alanpoulain
Copy link
Contributor Author

The related documentation has been updated. I've also added the allowEmpty prop, please tell me if you prefer to remove this change or have it in another PR (in the master branch I guess).

The code has been updated to follow your recommendation too.

And yes it replaces #2912.

@fzaninotto fzaninotto merged commit 6f9fd6a into marmelab:next Nov 24, 2019
@fzaninotto
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants