Skip to content

[Android] Don't reload on double R typed into a text field - #60516

Open
miniware9 wants to merge 2 commits into
react:mainfrom
miniware9:double-r-reload-text-editors
Open

miniware9 wants to merge 2 commits into
react:mainfrom
miniware9:double-r-reload-text-editors

Conversation

@miniware9

@miniware9 miniware9 commented Dec 3, 2026 •

Copy link
Copy Markdown

Summary:

In a debug build, DoubleTapReloadRecognizer reloads the JavaScript when R is pressed twice within 200 ms, unless the focused view is an EditText.
A text field that isn't an EditText gets no such exemption, so typing a word with two r's close together into it, such as "error", reloads the app and drops what was typed.
Jetpack Compose text fields are such fields: while one has focus, the focused view is Compose's AndroidComposeView. @expo/ui's TextInput renders one on Android, for example.
A text field in a Modal gets no exemption either, EditText or not: the Modal's dialog hands every key-up but Back and Escape on to the activity's onKeyUp, and ReactDelegate gives the recognizer activity.currentFocus, which is in the activity's window, never the dialog's.
Only key events reach the check, as a hardware keyboard sends them, such as the computer's keyboard typing into an emulator.

This change also exempts a focused view whose onCheckIsTextEditor() is true, the method Android documents for a view to say it is a text editor. AndroidComposeView returns true while one of its text fields has focus.
An EditText stays exempt as before, including one whose input type is TYPE_NULL, for which onCheckIsTextEditor() is false.
For a text field in another window, such as a Modal's, ReactDelegate skips the check while InputMethodManager.isAcceptingText() is true, as it is while a text field takes input.
With no text field focused, R twice still reloads, in a Modal too.

Reproducer: https://github.com/miniware9/react-native-android-double-r-reloads-while-typing

Changelog:

[ANDROID] [FIXED] - Typing R twice into a focused text field no longer reloads the app when the field isn't an EditText, such as a Jetpack Compose text field, or is in a Modal

Test Plan:

I ran the reproducer, a blank Expo SDK 58 app on React Native 0.88.1 with a Compose text field (@expo/ui's TextInput), a React Native TextInput and a focusable view that isn't a text field, on the screen and again in a Modal, as a debug build on an Android 17 emulator (x86_64).
I built it against 0.88.1's react-android as published, and again with this change: DoubleTapReloadRecognizer and ReactDelegate compiled from the patched sources, in place of the published classes in a copy of react-android-0.88.1-debug.aar served from a local Maven repository.
Each case starts from a fresh launch, and a reload is the app logging its JavaScript loading again after the keys were sent.
Each build gave the same results on two runs.

Focus Keys Before After
The focusable view adb shell input keyevent KEYCODE_R KEYCODE_R reloads reloads
The Compose text field adb shell input text rr reloads, and the field is empty types rr, no reload
The TextInput adb shell input text rr types rr, no reload types rr, no reload
The focusable view in the Modal adb shell input keyevent KEYCODE_R KEYCODE_R reloads reloads
The Compose text field in the Modal adb shell input text rr reloads, and the Modal closes types rr, no reload
The TextInput in the Modal adb shell input text rr reloads, and the Modal closes types rr, no reload

ktfmt 0.59.0, run as yarn format-kotlin runs it, leaves the changed files as they are.

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 3, 2026
@miniware9
miniware9 force-pushed the double-r-reload-text-editors branch from 1b2072f to cb7f028 Compare December 3, 2026 17:48
Signed-off-by: Swamini Kulkarni <swaminikulkarni1@gmail.com>
Signed-off-by: Swamini Kulkarni <swaminikulkarni1@gmail.com>
@miniware9
miniware9 force-pushed the double-r-reload-text-editors branch from cb7f028 to 5e40c42 Compare December 5, 2026 20:12
@miniware9 miniware9 changed the title [Android] Don't reload on double R typed into a non-EditText text field [Android] Don't reload on double R typed into a text field Dec 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant