diff --git a/lib/java/com/google/android/material/textfield/PasswordToggleEndIconDelegate.java b/lib/java/com/google/android/material/textfield/PasswordToggleEndIconDelegate.java index 1f6ad7fdd..34bb56851 100644 --- a/lib/java/com/google/android/material/textfield/PasswordToggleEndIconDelegate.java +++ b/lib/java/com/google/android/material/textfield/PasswordToggleEndIconDelegate.java @@ -99,7 +99,9 @@ class PasswordToggleEndIconDelegate extends EndIconDelegate { editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); } // And restore the cursor position - editText.setSelection(selection); + if (selection >= 0) { + editText.setSelection(selection); + } } }); textInputLayout.addOnEditTextAttachedListener(onEditTextAttachedListener);