When I'm testing the clearOnEscape variation of the Autocomplete component on docs and pressing escape causes the browser to exit from fullscreen
The browser state should not be affected by pressing escape
| Tech | Version |
| ----------- | ------- |
| Material-UI |current聽master|
| Browser| Opera v63.0.3368.107 |
| OS| macOs Mojave 10.14.6|
How do you trigger the "fullscreen" mode?
Browser | Opera v63.0.3368.107
Notice that we have no official support for this browser.
What do you think of a fix like this one?
diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index bc02f10f1..2df5b1c6f 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -513,9 +513,15 @@ export default function useAutocomplete(props) {
break;
case 'Escape':
if (popupOpen) {
+ // Avoid Opera to exit fullscreen mode.
+ event.preventDefault();
+ // Avoid the Modal to handle the event.
event.stopPropagation();
handleClose(event);
- } else if (clearOnEscape) {
+ } else if (clearOnEscape && inputValue !== '') {
+ // Avoid Opera to exit fullscreen mode.
+ event.preventDefault();
+ // Avoid the Modal to handle the event.
event.stopPropagation();
handleClear(event);
}
@oliviertassinari working on this
Most helpful comment
@oliviertassinari working on this