Skip to content

Commit

Permalink
[TextInputLayout] Limited the min height reset in text change listene…
Browse files Browse the repository at this point in the history
…r only when line count changes.

PiperOrigin-RevId: 582049113
  • Loading branch information
pekingme authored and dsn5ft committed Nov 13, 2023
1 parent d033733 commit 9b9449c
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,8 @@ private void setEditText(EditText editText) {
// Add a TextWatcher so that we know when the text input has changed.
this.editText.addTextChangedListener(
new TextWatcher() {
int previousLineCount = editText.getLineCount();

@Override
public void afterTextChanged(@NonNull Editable s) {
updateLabelState(!restoringSavedState);
Expand All @@ -1578,8 +1580,13 @@ public void afterTextChanged(@NonNull Editable s) {
if (placeholderEnabled) {
updatePlaceholderText(s);
}
if (ViewCompat.getMinimumHeight(editText) != originalEditTextMinimumHeight) {
editText.setMinimumHeight(originalEditTextMinimumHeight);
int currentLineCount = editText.getLineCount();
if (currentLineCount != previousLineCount) {
if (currentLineCount < previousLineCount
&& ViewCompat.getMinimumHeight(editText) != originalEditTextMinimumHeight) {
editText.setMinimumHeight(originalEditTextMinimumHeight);
}
previousLineCount = currentLineCount;
}
}

Expand Down

0 comments on commit 9b9449c

Please sign in to comment.