Skip to content

Commit

Permalink
Merge pull request #26399 from bernhardoj/fix/25508-input-label-deact…
Browse files Browse the repository at this point in the history
…ivate

Fix input label is deactivated even when there is a value
  • Loading branch information
Beamanator authored Sep 1, 2023
2 parents ec95ab0 + 3280ea3 commit c3ec03b
Showing 1 changed file with 7 additions and 7 deletions.
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
// 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

0 comments on commit c3ec03b

Please sign in to comment.