-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[TextField] Label shrink issue with disableGlobal: true #19224
Comments
Wow, this is an amazing side effect (unexpected). If somebody wants to investigate, it can start here: |
^^ yes ! If you move your mouse on the page (codesandbox) then you refresh the page on the same time most of time it works ! If you stop moving and you refresh you got the error again. :S |
The use of One proposal is an extra option, similar to how the inclusion option of theme is done, e.g.
|
We will soon have to solve the same issue with styled-components and emotion (multi-engine support). They both give us access to the generated name of the keyframe but with our current integration with JSS, it's more challenging. In this context, what about we use global, prefixed, names? diff --git a/packages/material-ui/src/InputBase/InputBase.js b/packages/material-ui/src/InputBase/InputBase.js
index 3ce557f0b..caded0597 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,
@@ -388,7 +390,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' },
+ event.animationName === 'mui-auto-fill-cancel' ? inputRef.current : { value: 'x' },
);
}; |
I agree, it seems like a cleaner approach. It feels bloated having to supply the sheet as I proposed for one particular use-case. |
@martinjlowm Great, in this case, feel free to take the lead to get these changes in the master branch :). |
Current Behavior 😯
When we build an application in production and we add the variable at true for disableGlobal inside createGenerateClassName, TextField is shrinked automatically by default without value.
Expected Behavior 🤔
Should not be shrinked.
Steps to Reproduce 🕹
https://codesandbox.io/s/material-ui-error-input-4y9hv
Doesn't work on chrome and firefox but works on Safari. If you put disableGlobal at false it's work everywhere
The text was updated successfully, but these errors were encountered: