Repository navigation
Treat a vertical drag that scrolls a TextInput as a native gesture on Android - #60528
Open
leeseonghyun21 wants to merge 1 commit into
Open
leeseonghyun21 wants to merge 1 commit into
leeseonghyun21 wants to merge 1 commit into
Conversation
… Android Signed-off-by: leeseonghyun21 <33210765+leeseonghyun21@users.noreply.github.com>
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 short vertical drag on the text of an unfocused multiline
TextInputthat has more text than fits scrolls the text, and then, on release:The drag is never handed to native the way a
ScrollViewdrag is. The JS touch stays active, soPressabilitytreats a short drag inside the input as a press, andTextInput'sonPressfocuses it on release. Focusing anEditTextbrings the caret into view, which scrolls the text back.A drag that cannot scroll the text further (for example, at the end of the text) has a second path to the same result:
TextView.onTouchEventfocuses the input itself onACTION_UPwhen the touch did not scroll it.This is separate from #58678, which lets a parent
ScrollViewtake a gesture the input cannot scroll. Here the input does scroll, and the problem is what happens on release.Changes in
ReactEditText.onTouchEvent:NativeGestureUtil.notifyNativeGestureStarted, asReactScrollViewdoes when it starts dragging. This cancels the JS touch. Waiting for the text to scroll first matters: cancelling earlier also stopped the scroll that was about to start (checked on an emulator).ACTION_UP/ACTION_CANCELof that gesture, callnotifyNativeGestureEnded.ACTION_UPof that gesture toTextViewasACTION_CANCEL(a copy, since ancestors keep reading the original event), soTextViewdoes not focus it either.A tap and a long press behave as before.
Changelog:
[ANDROID] [FIXED] - Dragging the text of an unfocused multiline TextInput no longer focuses it and scrolls it back on release
Test Plan:
RNTester Playground with this reproducer (Pixel 9 Pro Fold emulator, API 36):
The text starts scrolled to the end. Without tapping first, drag down by about 50 px (the text scrolls up) and release; then, from a fresh mount, drag up (the text is already at the end and cannot scroll further) and release. Drags were sent with
adb shell input touchscreen swipe(finger, 300 ms).mainonFocus, keyboard opens, scroll offset jumps back to the caret (412 → 426)onFocus, keyboard opensA longer drag (past the press area) did not focus the input on
maineither; that is the casePressabilityalready cancels.ktfmt with the
yarn format-check-kotlinsettings passes on the changed file.🤖 Generated with Claude Code