Skip to content

Commit

Permalink
Fixing focus order when text fields have the password toggle enabled.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 227893863
  • Loading branch information
leticiarossi authored and ikim24 committed Jan 10, 2019
1 parent 7adbeac commit 9a30c93
Showing 1 changed file with 11 additions and 5 deletions.
Expand Up @@ -1875,11 +1875,17 @@ public void onClick(View view) {
});
}

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

passwordToggleView.setVisibility(VISIBLE);
Expand Down

0 comments on commit 9a30c93

Please sign in to comment.