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

Fix unnecessary AutocompleteArrayInput filter reset #4653

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

Kmaschta
Copy link
Contributor

@Kmaschta Kmaschta commented Apr 7, 2020

Fixes #4454

Ok, this solution is not the best I can find.
@fzaninotto's idea is to let the user deal this situtation.

If the user write a tricky parse function, it's his job to make sure the input do not refresh too much by having a useMemo or useCallback above.
The issue is that I can't make it work since parse is a function that I cannot define with its value.

Considered alternatives

  • Force the user who wrote the parse function to wrap the AutocompleteArrayInput into an appropriate memo or useCallback
    The issue is that I didn't succeed so because we can't access to the input values outside of this component, so we can't use it as a dependency for useCallback, for example
    I didn't tried with a FormDataConsumer, it would not be developer friendly IMHO

  • Use hash-sum to hash input.value inside the useEffect dependency. It works, but I'm wondering if it's necessary to add a new library in the dependencies for that purpose

@Kmaschta Kmaschta added the RFR Ready For Review label Apr 7, 2020
@Kmaschta Kmaschta added this to the 3.4.1 milestone Apr 7, 2020
@Kmaschta Kmaschta force-pushed the fix-autocomplete-array-input-dependencies branch from b16e8c9 to d895bf0 Compare April 7, 2020 10:17
@Kmaschta Kmaschta force-pushed the fix-autocomplete-array-input-dependencies branch from d895bf0 to f8084bc Compare April 7, 2020 10:23
@Kmaschta Kmaschta force-pushed the fix-autocomplete-array-input-dependencies branch from f8084bc to d493249 Compare April 7, 2020 10:25
@fzaninotto fzaninotto merged commit c10a5d5 into master Apr 8, 2020
@fzaninotto fzaninotto deleted the fix-autocomplete-array-input-dependencies branch April 8, 2020 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using parse/format with AutoCompleteArrayInput and ReferenceArrayInput
2 participants