Repository navigation
Commit 7974af7
Fix TextInput breaking nested scroll gestures on Android (#58757)
Summary:
Pull Request resolved: #58757
Fixes an Android-only bug where TextInputs can interfere with nested scroll gestures, causing scroll events to be performed on the outer parent instead of the inner ScrollView.
### Root Cause
This issue occurs when you have a TextInput inside an inner ScrollView with `nestedScrollEnabled = true` inside an outer ScrollView. When a scroll gesture is performed on a TextInput that can scroll, the TextInput intercepts the gesture as expected. However, the next scroll gesture applied anywhere in the inner ScrollView scrolls the outer parent instead of the inner ScrollView.
`inner.onInterceptTouchEvent()` calls `startNestedScroll()` on ACTION_DOWN and `stopNestedScroll()` on ACTION_UP. When the scroll gesture is on a scrollable TextInput, ReactEditText disallows parent views from intercepting touch events. This means on ACTION_UP, `inner.onInterceptTouchEvent()` and `stopNestedScroll()` is not triggered.
Without `stopNestedScroll()`, the subsequent `startNestedScroll()` on the next ACTION_DOWN becomes a no-op, and the outer ScrollView intercepts the scroll gesture instead of the inner ScrollView.
### This PR
Add a defensive `stopNestedScroll()` in `dispatchTouchEvent()` for ScrollViews. This matches the existing pattern already used by Android in `View.dispatchTouchEvent()` which includes the exact same defensive cleanup.
Changelog: [Android][Fixed] - Prevent TextInputs from interfering with nested scroll gestures
Reviewed By: festus14
Differential Revision: D122404118
fbshipit-source-id: 72909f0ab38298b28386e3a328db86732b2fd80a1 parent 089b690 commit 7974af7
4 files changed
Lines changed: 27 additions & 1 deletion
File tree
- packages/react-native/ReactAndroid
- api
- src/main/java/com/facebook/react/views/scroll
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5478 | 5478 | | |
5479 | 5479 | | |
5480 | 5480 | | |
| 5481 | + | |
5481 | 5482 | | |
5482 | 5483 | | |
5483 | 5484 | | |
| |||
5626 | 5627 | | |
5627 | 5628 | | |
5628 | 5629 | | |
| 5630 | + | |
5629 | 5631 | | |
5630 | 5632 | | |
5631 | 5633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
648 | 656 | | |
649 | 657 | | |
650 | 658 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
568 | 576 | | |
569 | 577 | | |
570 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
560 | 568 | | |
561 | 569 | | |
562 | 570 | | |
| |||
0 commit comments