Skip to content

Commit

Permalink
[TextInputLayout] Fixed unnecessary min height when losing focus with…
Browse files Browse the repository at this point in the history
… multiple lines.

Resolves #3451

PiperOrigin-RevId: 579017528
  • Loading branch information
pekingme authored and paulfthomas committed Nov 6, 2023
1 parent f3e4439 commit 4a2654a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ public interface OnEndIconChangedListener {

@ColorInt private int disabledColor;

int originalEditTextMinimumHeight;

// Only used for testing
private boolean hintExpanded;

Expand Down Expand Up @@ -1562,6 +1564,8 @@ private void setEditText(EditText editText) {
Gravity.TOP | (editTextGravity & ~Gravity.VERTICAL_GRAVITY_MASK));
collapsingTextHelper.setExpandedTextGravity(editTextGravity);

originalEditTextMinimumHeight = ViewCompat.getMinimumHeight(editText);

// Add a TextWatcher so that we know when the text input has changed.
this.editText.addTextChangedListener(
new TextWatcher() {
Expand All @@ -1574,6 +1578,9 @@ public void afterTextChanged(@NonNull Editable s) {
if (placeholderEnabled) {
updatePlaceholderText(s);
}
if (ViewCompat.getMinimumHeight(editText) != originalEditTextMinimumHeight) {
editText.setMinimumHeight(originalEditTextMinimumHeight);
}
}

@Override
Expand Down

0 comments on commit 4a2654a

Please sign in to comment.