Skip to content

Commit 9a30c93

Browse files
leticiarossiikim24
authored andcommitted
Fixing focus order when text fields have the password toggle enabled.
PiperOrigin-RevId: 227893863
1 parent 7adbeac commit 9a30c93

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,11 +1875,17 @@ public void onClick(View view) {
18751875
});
18761876
}
18771877

1878-
if (editText != null && ViewCompat.getMinimumHeight(editText) <= 0) {
1879-
// We should make sure that the EditText has the same min-height as the password toggle
1880-
// view. This ensures focus works properly, and there is no visual jump if the password
1881-
// toggle is enabled/disabled.
1882-
editText.setMinimumHeight(ViewCompat.getMinimumHeight(passwordToggleView));
1878+
if (editText.getMeasuredHeight() < passwordToggleView.getMeasuredHeight()) {
1879+
// We need to make sure that the EditText's height is at least the same as the password
1880+
// toggle's height. This ensures focus works properly, and there is no visual jump if the
1881+
// password toggle is enabled/disabled.
1882+
editText.setMinimumHeight(passwordToggleView.getMeasuredHeight());
1883+
editText.post(new Runnable() {
1884+
@Override
1885+
public void run() {
1886+
editText.requestLayout();
1887+
}
1888+
});
18831889
}
18841890

18851891
passwordToggleView.setVisibility(VISIBLE);

0 commit comments

Comments
 (0)