Skip to content

Commit d5b2d81

Browse files
leticiarossiikim24
authored andcommitted
Fixing crash happening when password toggle is clicked without the edit text having focus in TalkBack mode.
PiperOrigin-RevId: 286590576 (cherry picked from commit 8ed0ab7)
1 parent c6812b2 commit d5b2d81

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ public void onClick(View v) {
9999
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
100100
}
101101
// And restore the cursor position
102-
editText.setSelection(selection);
102+
if (selection >= 0) {
103+
editText.setSelection(selection);
104+
}
103105
}
104106
});
105107
textInputLayout.addOnEditTextAttachedListener(onEditTextAttachedListener);

0 commit comments

Comments
 (0)