From 332b6c89ea46213f284f62f162ec3e16025f32ab Mon Sep 17 00:00:00 2001 From: Martin Jesper Low Madsen Date: Fri, 31 Jan 2020 14:09:54 +0100 Subject: [PATCH 1/2] [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. --- .../material-ui/src/InputBase/InputBase.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/material-ui/src/InputBase/InputBase.js b/packages/material-ui/src/InputBase/InputBase.js index 3ce557f0be404a..955a57f420df61 100644 --- a/packages/material-ui/src/InputBase/InputBase.js +++ b/packages/material-ui/src/InputBase/InputBase.js @@ -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. @@ -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 @@ -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, @@ -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(() => { From cf1a64ec58b6f9891209a36c945528eb7c41e4b3 Mon Sep 17 00:00:00 2001 From: Martin Jesper Low Madsen Date: Fri, 31 Jan 2020 14:39:25 +0100 Subject: [PATCH 2/2] [Docs] Disable style documentation for @global identifiers --- docs/src/modules/utils/generateMarkdown.js | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/modules/utils/generateMarkdown.js b/docs/src/modules/utils/generateMarkdown.js index 538a25cff9a15d..eceda588d4048d 100644 --- a/docs/src/modules/utils/generateMarkdown.js +++ b/docs/src/modules/utils/generateMarkdown.js @@ -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];