-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Warn when using wrong getOptionSelected #19699
[Autocomplete] Warn when using wrong getOptionSelected #19699
Conversation
No bundle size changes comparing 5ed8d0a...0bd00e0 |
@ahmad-reza619 Thanks, it would be perfect with a test case. |
@oliviertassinari alright, will do |
I'm a bit confused as to where to put the test case, Autocomplete or useAutoComplete? 🤔 sorry btw i'm new when it comes to testing |
packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
Outdated
Show resolved
Hide resolved
@ahmad-reza619 Do you think that you could add a test case? :) |
i'll do but it's kinda hard for me 😢 i don't understand about testing and this lib surely huge😅 i would like some guidance 😄 |
do i have to only give getOptionSelected props in testing 🤔 and also am i have to use stub or spy to replicate it's functionality. 😓 sorry btw still confused here |
Try writing a component that passes props to Autocomplete so that this warning is triggered. For how to assert on the warning you could use https://github.com/mui-org/material-ui/blob/f57707d1c328d22e2ce46dd12f08164271534f90/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js#L84-L110 as an inspiration. |
@eps1lon but this one a little bit complex i think 🤔 because you have to make a component to assert this behavior. and there's no example that i can use 😓 |
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.
Don't worry, writing a test case can be challenging. It requires a deep understanding of what's going on. I have added one, I think that we can move forward :)
Thank you so much for the help, but it's fail? is it because of the test 🤔 ? |
Azure pipeline has been unreliable since yesterday, I don't know if the issue is on our side, there are out of memory crashes. Reruning solves the problem. To monitor. Thanks. |
@oliviertassinari |
Close #19595
I followed what suggested in the issue, but i suggest to change the props
getOptionSelected
to be more precise. It can be as what suggested by @oliviertassinari likeoptionEqualValue
, or my recommendation isgetSelectedOption
. but it's up to you guys (actually i had a little hard time thinking what this props does, but i don't know if it's will become a breaking change 🤔 )i used array filter here. it does support all kinds of browsers except IE 6-8 based on this report
Have a nice day 😄