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

[Autocomplete] Fix calling onChange for duplicate values #30374

Merged
merged 3 commits into from
Dec 30, 2021

Conversation

alisasanib
Copy link
Contributor

@alisasanib alisasanib commented Dec 22, 2021

Fixes #30150

Problem:

  • Duplicate values call the onChange function in Autocomplete component because it only shallowly compares value and newValue.

Solution:

  • Deep comparison between value and newValue, in order to not call the onChange if they have equal elements.

codesandbox working example

@mui-pr-bot
Copy link

mui-pr-bot commented Dec 22, 2021

Details of bundle changes

Generated by 🚫 dangerJS against 648d8c7

@alisasanib alisasanib changed the title Fix on change for duplicate values [AutoComplete] Fix calling onChange for duplicate values Dec 22, 2021
@oliviertassinari oliviertassinari changed the title [AutoComplete] Fix calling onChange for duplicate values [Autocomplete] Fix calling onChange for duplicate values Dec 23, 2021
@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Dec 23, 2021
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

The logic looks good to me

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

Yup, both the implementation and the test look fine. Thanks for your contribution!

@michaldudak michaldudak merged commit dc3b696 into mui:master Dec 30, 2021
@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Dec 31, 2021
@alisasanib alisasanib deleted the fix-onChange-for-duplicate-values branch January 26, 2022 13:55
wladimirguerra pushed a commit to wladimirguerra/material-ui that referenced this pull request Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AutoComplete] onChange being called when value is duplicated
5 participants