Skip to content

Commit 4a2654a

Browse files
pekingmepaulfthomas
authored andcommitted
[TextInputLayout] Fixed unnecessary min height when losing focus with multiple lines.
Resolves #3451 PiperOrigin-RevId: 579017528
1 parent f3e4439 commit 4a2654a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/java/com/google/android/material/textfield/TextInputLayout.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ public interface OnEndIconChangedListener {
440440

441441
@ColorInt private int disabledColor;
442442

443+
int originalEditTextMinimumHeight;
444+
443445
// Only used for testing
444446
private boolean hintExpanded;
445447

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

1567+
originalEditTextMinimumHeight = ViewCompat.getMinimumHeight(editText);
1568+
15651569
// Add a TextWatcher so that we know when the text input has changed.
15661570
this.editText.addTextChangedListener(
15671571
new TextWatcher() {
@@ -1574,6 +1578,9 @@ public void afterTextChanged(@NonNull Editable s) {
15741578
if (placeholderEnabled) {
15751579
updatePlaceholderText(s);
15761580
}
1581+
if (ViewCompat.getMinimumHeight(editText) != originalEditTextMinimumHeight) {
1582+
editText.setMinimumHeight(originalEditTextMinimumHeight);
1583+
}
15771584
}
15781585

15791586
@Override

0 commit comments

Comments
 (0)