-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Shrink form label when input is autofilled #3372
Conversation
@antoinerousseau very cool! excited to see how this goes. is this failing test something related to your code or some other type of test failure? |
@@ -289,6 +289,7 @@ const TextField = React.createClass({ | |||
|
|||
return { | |||
isFocused: false, | |||
isAutofilled: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the hasValue
state instead of this new isAutofilled
even if we can't read the value for security converns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i don't see why not :)
That looks good to me 👍. |
@@ -351,7 +351,17 @@ const TextField = React.createClass({ | |||
}, | |||
|
|||
_handleInputChange(e) { | |||
this.setState({hasValue: isValid(e.target.value)}); | |||
let isAutofilled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, what do you think about running this test only if isValid(e.target.value)
is false
?
We could save some CPU cycles :). I don't know how expensive a try / catch
and matches
is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right!
wait, i'm having a weird bug where chrome takes a millisecond or two between dispatching the |
I could not come up with a better solution than checking the pseudo class after the component is mounted, since Chrome 48 does not dispatch a But anyway, now it works well if you don't mind the timer ^^' |
@newoga - tagging you because I know you have an aversion to timers. 😄 Not sure there's an alternative though. |
I want to put this on hold for now. I'm not completely thrilled with this implementation (though not just because of the timer, so not @antoinerousseau's fault). The reality is we want TextField to become a controlled component, but there's not really an easy and natural way to use the input value that was set from autofill events. This topic is being discussed in both the React and Angular communities (such as facebook/react#1159). Furthermore, based on the little I read, there may be edge cases that involve browsers outside of Chrome. I'm hesitant to put this logic in the TextField's If we wanted to go down this path, I'd probably argue for creating a separate |
Fixes #718.