Skip to content

Commit f99303c

Browse files
YevheniiKotyrlometa-codesync[bot]
authored andcommitted
Fix Android visible-password keyboard input type (#59013)
Summary: `keyboardType="visible-password"` reaches Android with no input class. `setKeyboardType` applies `flagsToSet` with `TYPE_MASK_CLASS` as the mask to clear, and that arm sets only `TYPE_TEXT_VARIATION_VISIBLE_PASSWORD` (`0x90`), so the input method receives class `TYPE_NULL`, which `InputType` defines as a connection that cannot show candidate text or retrieve the current text. #58505 fixed the same omission in the `url` arm; this gives `visible-password` the `TYPE_CLASS_TEXT` the `email-address` and `url` arms already set. `testKeyboardTypeVisiblePassword` could not see it: `generalKeyboardTypeFlags` masks out `TYPE_TEXT_VARIATION_PASSWORD`, so the test compared `0x10` and passed with the class missing. It now asserts the class and the variation exactly. ## Changelog: [ANDROID] [FIXED] - Restore the text input class for visible-password keyboard types Pull Request resolved: #59013 Test Plan: - `./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests "com.facebook.react.views.textinput.ReactTextInputPropertyTest" -Preact.internal.useHermesStable=true`: on `main` the updated test fails with `expected:<145> but was:<144>` (`0x91` against `0x90`); with the fix all 28 tests in the class pass. - `./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest -PenableWarningsAsErrors=true -Preact.internal.useHermesStable=true`: 674 tests, 0 failures. - `node ./scripts/format-kotlin.js --check` passes. - Not run: the RNTester build and Android lint (`build_android`). Reviewed By: cortinico Differential Revision: D124966195 Pulled By: javache fbshipit-source-id: 64161cb4c2a41a044a215aa9fcb1a163de9876e6
1 parent 9979e14 commit f99303c

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ public open class ReactTextInputManager public constructor() :
758758
} else if (KEYBOARD_TYPE_VISIBLE_PASSWORD.equals(keyboardType, ignoreCase = true)) {
759759
// This will supersede secureTextEntry={false}. If it doesn't, due to the way
760760
// the flags work out, the underlying field will end up a URI-type field.
761-
flagsToSet = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
761+
flagsToSet = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
762762
} else if (KEYBOARD_TYPE_URI.equals(keyboardType, ignoreCase = true)) {
763763
flagsToSet = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI
764764
}

‎packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.kt‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,9 @@ class ReactTextInputPropertyTest {
386386

387387
@Test
388388
fun testKeyboardTypeVisiblePassword() {
389-
val passwordVisibilityFlag =
390-
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD and
391-
InputType.TYPE_TEXT_VARIATION_PASSWORD.inv()
392-
393389
manager.updateProperties(view, buildStyles("keyboardType", "visible-password"))
394-
assertThat(view.inputType and generalKeyboardTypeFlags).isEqualTo(passwordVisibilityFlag)
390+
assertThat(view.inputType and (InputType.TYPE_MASK_CLASS or InputType.TYPE_MASK_VARIATION))
391+
.isEqualTo(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD)
395392
}
396393

397394
@Test

0 commit comments

Comments
 (0)