Skip to content

Commit 89e28bb

Browse files
committed
Apply selection position logic at the time of commiting flags.
1 parent e4c87d4 commit 89e28bb

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ public String getReturnKeyType() {
309309

310310
/*package*/ void commitStagedInputType() {
311311
if (getInputType() != mStagedInputType) {
312+
int selectionStart = getSelectionStart();
313+
int selectionEnd = getSelectionEnd();
312314
setInputType(mStagedInputType);
315+
setSelection(selectionStart, selectionEnd);
313316
}
314317
}
315318

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,12 @@ public void setMultiline(ReactEditText view, boolean multiline) {
519519

520520
@ReactProp(name = "secureTextEntry", defaultBoolean = false)
521521
public void setSecureTextEntry(ReactEditText view, boolean password) {
522-
int selectionStart = view.getSelectionStart();
523-
view.setTransformationMethod(password ? new PasswordTransformationMethod() : null);
522+
updateStagedInputTypeFlag(
523+
view,
524+
password ? 0 :
525+
InputType.TYPE_NUMBER_VARIATION_PASSWORD | InputType.TYPE_TEXT_VARIATION_PASSWORD,
526+
password ? InputType.TYPE_TEXT_VARIATION_PASSWORD : 0);
524527
checkPasswordType(view);
525-
view.setSelection(selectionStart);
526528
}
527529

528530
@ReactProp(name = "autoCapitalize")

0 commit comments

Comments
 (0)