Skip to content

Commit

Permalink
[InputBase] Declare global mui-auto-fill(-cancel) keyframes (mui#19497)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjlowm authored and EsoterikStare committed Feb 13, 2020
1 parent 8039e58 commit f2a36f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/src/modules/utils/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ function generateClasses(reactAPI) {
text = `| Rule name | Global class | Description |
|:-----|:-------------|:------------|\n`;
text += reactAPI.styles.classes
.filter(cls => cls !== '@global')
.map(styleRule => {
const description = reactAPI.styles.descriptions[styleRule];

Expand Down
22 changes: 11 additions & 11 deletions packages/material-ui/src/InputBase/InputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export const styles = theme => {
};

return {
'@global': {
'@keyframes mui-auto-fill': {
from: {},
},
'@keyframes mui-auto-fill-cancel': {
from: {},
},
},
/* Styles applied to the root element. */
root: {
// Mimics the default input display property used by browsers for an input.
Expand Down Expand Up @@ -87,7 +95,7 @@ export const styles = theme => {
// Make the flex item shrink with Firefox
minWidth: 0,
width: '100%', // Fix IE 11 width issue
animationName: '$auto-fill-cancel',
animationName: 'mui-auto-fill-cancel',
'&::-webkit-input-placeholder': placeholder,
'&::-moz-placeholder': placeholder, // Firefox 19+
'&:-ms-input-placeholder': placeholder, // IE 11
Expand Down Expand Up @@ -119,15 +127,9 @@ export const styles = theme => {
},
'&:-webkit-autofill': {
animationDuration: '5000s',
animationName: '$auto-fill',
animationName: 'mui-auto-fill',
},
},
'@keyframes auto-fill': {
from: {},
},
'@keyframes auto-fill-cancel': {
from: {},
},
/* Styles applied to the `input` element if `margin="dense"`. */
inputMarginDense: {
paddingTop: 4 - 1,
Expand Down Expand Up @@ -387,9 +389,7 @@ const InputBase = React.forwardRef(function InputBase(props, ref) {

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

React.useEffect(() => {
Expand Down

0 comments on commit f2a36f7

Please sign in to comment.