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 crash in multiple selection mode #18221

Closed
2 tasks done
stevemoncada opened this issue Nov 5, 2019 · 2 comments · Fixed by #18229
Closed
2 tasks done

Autocomplete crash in multiple selection mode #18221

stevemoncada opened this issue Nov 5, 2019 · 2 comments · Fixed by #18229
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@stevemoncada
Copy link

When multiple selections are enabled on an Autocomplete component, it's possible to crash the component by

  1. Clearing all options
  2. Selecting a valid option
  3. Pressing Enter

This can be duplicated on the Autocomplete demo page.

ezgif com-video-to-gif

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

I am using a similar getOptionLabel function as the demo page, where the title property of the given option is returned as the label. Instead of the Enter keypress being ignored when no value is selected, an undefined filter value is passed along and the getOptionLabel can't resolve a property of an undefined error.

Expected Behavior 🤔

Empty filter values should short-circuit long before the getOptionLabel function is called.

Steps to Reproduce 🕹

See above.

Context 🔦

A workaround for this looks like this in code:

getOptionLabel={option => (option ? option.title : '')}

and this in the Autocomplete text field...

Screen Shot 2019-11-05 at 3 46 27 PM

... which is nasty.

Your Environment 🌎

As mentioned above, this happens on the Autocomplete demo page using Chrome 78. This seems like a pretty straightforward bug.

@joshwooding joshwooding added bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module! labels Nov 5, 2019
@oliviertassinari oliviertassinari added the good first issue Great for first contributions. Enable to learn the contribution process. label Nov 5, 2019
@oliviertassinari
Copy link
Member

@stevemoncada Thank you for the report, It's the same root cause as #18211. The proposed fix applies here too.

@oliviertassinari
Copy link
Member

Maybe Sunday

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! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants