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

Fix input label is deactivated even when there is a value #26399

Merged
Merged
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
14 changes: 7 additions & 7 deletions src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ function BaseTextInput(props) {
props.onBlur(event);
}
setIsFocused(false);

// If the text has been supplied by Chrome autofill, the value state is not synced with the value
// as Chrome doesn't trigger a change event. When there is autofill text, don't deactivate label.
if (!isInputAutoFilled(input.current)) {
deactivateLabel();
}
};

const onPress = (event) => {
Expand Down Expand Up @@ -190,7 +184,13 @@ function BaseTextInput(props) {
// We can't use inputValue here directly, as it might contain
// the defaultValue, which doesn't get updated when the text changes.
// We can't use props.value either, as it might be undefined.
if (hasValueRef.current || isFocused || isInputAutoFilled(input.current)) {
if (
hasValueRef.current ||
isFocused ||
// If the text has been supplied by Chrome autofill, the value state is not synced with the value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff block is just moving the comment, am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

// as Chrome doesn't trigger a change event. When there is autofill text, keep the label activated.
isInputAutoFilled(input.current)
) {
activateLabel();
} else {
deactivateLabel();
Expand Down
Loading