You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:TextInputLayout.updateEditTextHeightBasedOnIcon() may set a wrong minimum height that lingers around. This is basically another way to reproduce #3451 where 4a2654a didn't fix the issue.
Expected behavior:TextInputLayout should resize with text.
Source code: The code snippet which is causing this issue
if (editText.getMeasuredHeight() < maxIconHeight) {
editText.setMinimumHeight(maxIconHeight);
returntrue;
}
returnfalse;
}
It only ever sets the minimum height but doesn't reset it. And in case the EndCompoundLayout becomes GONE due to icon becoming hidden, the EndCompoundLayout won't participate in the next layout and thus EndCompoundLayout.getMeasuredHeight() would return a stale height.
The fix in 4a2654a used a TextWatcher to reset the minimum height, however it won't work if the EndCompoundLayout is becoming GONE after the text change, e.g. when the app removes the error state (and thus removing the error icon), before re-layout for the previous text change happened.
It seems to me the code in updateEditTextHeightBasedOnIcon() should inspect the visibility of EndCompoundLayout before using its measured height, and manually use 0 in the case EndCompoundLayout is GONE. It should also reset the minimum height when measure height of EndCompoundLayout is smaller and the minimum height of the edit text is different (this way we prevent loops).
// Wait for layout and draw then in a separate place...
textInputEditText.setText("a")
textInputLayout.error =null
An actual example can be found at zhanghai/MaterialFiles@10a67dd and its APK artifact, by opening the file manager app, opening properties of a regular file and go to the checksum tab, put a multi-line inconsistent checksum (e.g. copy-pasting SHA-256 sum twice) into the "Compare" edit text and then clear the edit text.
Android API version: Android 14
Material Library version: 1.11.0 and 1.12.0-rc01
Device: Android Emulator Pixel 2 Android 14
The text was updated successfully, but these errors were encountered:
Description:
TextInputLayout.updateEditTextHeightBasedOnIcon()
may set a wrong minimum height that lingers around. This is basically another way to reproduce #3451 where 4a2654a didn't fix the issue.Expected behavior:
TextInputLayout
should resize with text.Source code: The code snippet which is causing this issue
material-components-android/lib/java/com/google/android/material/textfield/TextInputLayout.java
Lines 3310 to 3325 in 9393b97
It only ever sets the minimum height but doesn't reset it. And in case the
EndCompoundLayout
becomesGONE
due to icon becoming hidden, theEndCompoundLayout
won't participate in the next layout and thusEndCompoundLayout.getMeasuredHeight()
would return a stale height.The fix in 4a2654a used a
TextWatcher
to reset the minimum height, however it won't work if theEndCompoundLayout
is becomingGONE
after the text change, e.g. when the app removes the error state (and thus removing the error icon), before re-layout for the previous text change happened.It seems to me the code in
updateEditTextHeightBasedOnIcon()
should inspect the visibility ofEndCompoundLayout
before using its measured height, and manually use0
in the caseEndCompoundLayout
isGONE
. It should also reset the minimum height when measure height ofEndCompoundLayout
is smaller and the minimum height of the edit text is different (this way we prevent loops).Minimal sample app repro:
Something along the following lines:
An actual example can be found at zhanghai/MaterialFiles@10a67dd and its APK artifact, by opening the file manager app, opening properties of a regular file and go to the checksum tab, put a multi-line inconsistent checksum (e.g. copy-pasting SHA-256 sum twice) into the "Compare" edit text and then clear the edit text.
Android API version: Android 14
Material Library version: 1.11.0 and 1.12.0-rc01
Device: Android Emulator Pixel 2 Android 14
The text was updated successfully, but these errors were encountered: