Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[InputBase] Declare global mui-auto-fill(-cancel) keyframes #19497

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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