Repository navigation
Android: a TextInput with its context menu hidden takes no long press - #59130
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
A long press on an Android TextInput selects the word under the finger and focuses the field so the text action menu can act on the selection. With contextMenuHidden set the menu never opens, so the long press only selected a word nothing could act on and focused the field with the keyboard down. ReactEditText is not long-clickable while contextMenuHidden is set: View never starts the long press, accessibility no longer offers one, and a press held on the field ends as a click when it lifts on it. TextView turns long-clicking back on when setInputType sets a key listener and when onAttachedToWindow makes the text selectable, so the gate sits in setLongClickable.
YevheniiKotyrlo
marked this pull request as ready for review
October 16, 2026 10:12
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
On Android, a
TextInputwithcontextMenuHiddenstill runs the long press that exists to open that menu. Holding a word selects it and focuses the field without opening the keyboard, and the menu never appears. Holding and sliding off the field before lifting leaves it focused too. The flag refused the long press until #45014, which replaced the long-click listener that consumed it with the action mode callback, and that callback runs only afterEditorhas selected the word.ReactEditTextis no longer long-clickable whilecontextMenuHiddenis set, soViewnever starts the long press and accessibility stops offering one. A held press then ends like a tap: lifted on the field, it places the caret and opens the keyboard; lifted elsewhere, it does nothing.TextViewturns long-clicking back on when it sets a key listener, which every keyboard type change does, and whenonAttachedToWindowmakes the text selectable, so the gate is insetLongClickable.Changelog:
[ANDROID] [FIXED] - A
TextInputwithcontextMenuHiddenno longer selects a word and takes focus on a long pressTest Plan:
New
ReactTextInputPropertyTest.testContextMenuHidden: the field is long-clickable by default; withcontextMenuHiddenit is not, and stays that way after setting the flag again, a keyboard type change, andsetTextIsSelectable(true)(whatonAttachedToWindowcalls); clearing the flag makes it long-clickable again. Onmainit fails at the second assertion.RNTester's Playground (
RNTesterPlayground.js) with this component:Playground
Press and hold the word "hold" for a second, then lift. On
mainthe word is selected and the field focused while it is held, and the keyboard stays down after the release: on Android 14 and 16 the caret moves to the end of the word, and on Android 10 the word stays selected. With this change nothing happens while it is held, and the release places the caret where the finger lifts and opens the keyboard. Press and hold, then slide off the field and lift: onmainthe field ends up focused, and with this change it stays unfocused. I checked it on RNTester debug builds ofmainand this branch on Android 10, 14 and 16 phones, with the same result on every round../gradlew :packages:react-native:ReactAndroid:testDebugUnitTest -PenableWarningsAsErrors=truepasses (757 tests), andnode ./scripts/format-kotlin.js --checkis clean.