Skip to content

Commit 845a4d1

Browse files
authored
[InputBase] Declare global mui-auto-fill(-cancel) keyframes (#19497)
1 parent 2fe947e commit 845a4d1

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

docs/src/modules/utils/generateMarkdown.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ function generateClasses(reactAPI) {
337337
text = `| Rule name | Global class | Description |
338338
|:-----|:-------------|:------------|\n`;
339339
text += reactAPI.styles.classes
340+
.filter(cls => cls !== '@global')
340341
.map(styleRule => {
341342
const description = reactAPI.styles.descriptions[styleRule];
342343

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

Lines changed: 11 additions & 11 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,
@@ -387,9 +389,7 @@ const InputBase = React.forwardRef(function InputBase(props, ref) {
387389

388390
const handleAutoFill = event => {
389391
// Provide a fake value as Chrome might not let you access it for security reasons.
390-
checkDirty(
391-
event.animationName.indexOf('auto-fill-cancel') !== -1 ? inputRef.current : { value: 'x' },
392-
);
392+
checkDirty(event.animationName === 'mui-auto-fill-cancel' ? inputRef.current : { value: 'x' });
393393
};
394394

395395
React.useEffect(() => {

0 commit comments

Comments
 (0)