Skip to content

Commit a66ec34

Browse files
author
Martin Jesper Low Madsen
committed
[InputBase] Declare global mui-auto-fill(-cancel) keyframes
Browser autofill workaround logic requires static animation name references for keyframes. Enabling disableGlobal renames such keyframes unless they are marked as global.
1 parent ac5c1ae commit a66ec34

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/material-ui/src/InputBase/InputBase.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export const styles = theme => {
2828
};
2929

3030
return {
31+
'@global': {
32+
'@keyframes mui-auto-fill': {
33+
from: {},
34+
},
35+
'@keyframes mui-auto-fill-cancel': {
36+
from: {},
37+
},
38+
},
3139
/* Styles applied to the root element. */
3240
root: {
3341
// Mimics the default input display property used by browsers for an input.
@@ -87,7 +95,7 @@ export const styles = theme => {
8795
// Make the flex item shrink with Firefox
8896
minWidth: 0,
8997
width: '100%', // Fix IE 11 width issue
90-
animationName: '$auto-fill-cancel',
98+
animationName: 'mui-auto-fill-cancel',
9199
'&::-webkit-input-placeholder': placeholder,
92100
'&::-moz-placeholder': placeholder, // Firefox 19+
93101
'&:-ms-input-placeholder': placeholder, // IE 11
@@ -119,15 +127,9 @@ export const styles = theme => {
119127
},
120128
'&:-webkit-autofill': {
121129
animationDuration: '5000s',
122-
animationName: '$auto-fill',
130+
animationName: 'mui-auto-fill',
123131
},
124132
},
125-
'@keyframes auto-fill': {
126-
from: {},
127-
},
128-
'@keyframes auto-fill-cancel': {
129-
from: {},
130-
},
131133
/* Styles applied to the `input` element if `margin="dense"`. */
132134
inputMarginDense: {
133135
paddingTop: 4 - 1,
@@ -388,7 +390,7 @@ const InputBase = React.forwardRef(function InputBase(props, ref) {
388390
const handleAutoFill = event => {
389391
// Provide a fake value as Chrome might not let you access it for security reasons.
390392
checkDirty(
391-
event.animationName.indexOf('auto-fill-cancel') !== -1 ? inputRef.current : { value: 'x' },
393+
event.animationName === 'mui-auto-fill-cancel' ? inputRef.current : { value: 'x' },
392394
);
393395
};
394396

0 commit comments

Comments
 (0)