-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Cannot delete multiple Chips with Escape Key #19709
Comments
@jcafiero Brilliant, thanks for reporting this bug. It should be an easy one to fix and write tests for. Feel free to go ahead :). |
As my understanding, |
@chaudharykiran that's fine with me. Yes, that is the desired behavior. |
For anyone looking at the problem, the fix should be about: diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index 9957ed76d..2f61a763e 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -628,7 +628,7 @@ export default function useAutocomplete(props) {
// Avoid the Modal to handle the event.
event.stopPropagation();
handleClose(event);
- } else if (clearOnEscape && inputValue !== '') {
+ } else if (clearOnEscape && (inputValue !== '' || (multiple && value.length > 0))) {
// Avoid Opera to exit fullscreen mode.
event.preventDefault();
// Avoid the Modal to handle the event. Then, it's about adding a test case to prevent regressions in the future. |
Hi, can we do a PR to fix this tonight ? |
@yann120 I was working at Doctolib, sounds great! 😆 |
I am afraid, I may not be able to send PR for this tonight. cc. @oliviertassinari @yann120 |
Hey @oliviertassinari , we fix it yesterday at Doctolib event with your advices. But we write a new test and we can't make it pass... But we are working on it and try to understand why 👍 |
Current Behavior 😯
Currently, if you hit the Escape key while focused in a multi-select Autocomplete with the
clearOnEscape
prop it will not clear the Chips from the window.One behavior I did notice was that if there is still active text in the field, hitting the Escape Key twice would clear everything from the Autocomplete.
Expected Behavior 🤔
If you hit the Escape key while focused in a multi-select Autocomplete with the
clearOnEscape
prop, it should clear the Chips, similar to how clicking on the 'X' icon will clear all of the Chips from the field. This behavior should be consistent whether or not there is partially filled text or not in the Autocomplete.Steps to Reproduce 🕹
Here is a CodeSandbox: https://codesandbox.io/s/cranky-dhawan-2smfv?fontsize=14&hidenavigation=1&theme=dark
Steps:
Context 🔦
This is an accessibility bug that should be resolved to give keyboard users the same experience.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: