Files
paseo/patches/react-native+0.86.3.patch
T
Mohamed Boudra ca514b34a7 Keep Android composer buttons working on the first tap (#10308)
* fix(app): keep mobile composer buttons working on the first tap

After an unmatched native touch start (such as dismissing an Android Modal while a finger is down, double ACTION_DOWN in ReactRootView/ReactModalHostView, or a dropped synthetic ACTION_CANCEL), ReactFabric's ResponderEventPlugin left trackedTouchCount > 0 for the rest of the session because it only incremented/decremented by 1 instead of reconciling with nativeEvent.touches.length.

On Android, @mattermost/react-native-paste-input's PasteTextInput also set onSelectionChangeShouldSetResponder={emptyFunctionThatReturnsTrue} (which React Native core only sets on iOS). Whenever trackedTouchCount stayed > 0, every keystroke in the composer triggered topSelectionChange and let PasteTextInput claim the JS responder, swallowing the first tap on Send or any toolbar button.

Reconcile trackedTouchCount from nativeEvent.touches.length in ReactFabric (dev, prod, profiling) and ReactNativeResponder, remove the iOS-only onSelectionChangeShouldSetResponder prop from Android PasteTextInput, and drop the now-redundant createReactCancelEvent multi-pointer workaround from react-native-gesture-handler.

* fix(app): clear stale touchBank contacts when native touches reach zero

When a multi-touch gesture is cancelled by a single-pointer synthetic ACTION_CANCEL (or a prior touch end was dropped), ResponderTouchHistoryStore.recordTouchTrack only ended contacts listed in changedTouches, leaving other touchBank entries marked touchActive = true even though nativeEvent.touches.length was 0.

Mark all remaining active touchBank entries inactive whenever topTouchEnd or topTouchCancel reports 0 active native touches, so onResponderTerminate sees a clean touchHistory without needing RNGH's createReactCancelEvent workaround.
2026-11-21 13:20:02 +07:00

224 lines
9.6 KiB
Diff

diff --git a/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js b/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js
index daab0e3..d3a629c 100644
--- a/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js
+++ b/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js
@@ -16214,12 +16214,21 @@ __DEV__ &&
else if (
"topTouchEnd" === topLevelType ||
"topTouchCancel" === topLevelType
- )
- if (
- (nativeEvent.changedTouches.forEach(recordTouchEnd),
- (touchHistory.numberActiveTouches = nativeEvent.touches.length),
- 1 === touchHistory.numberActiveTouches)
- ) {
+ ) {
+ nativeEvent.changedTouches.forEach(recordTouchEnd);
+ touchHistory.numberActiveTouches = nativeEvent.touches.length;
+ if (0 === touchHistory.numberActiveTouches) {
+ for (
+ topLevelType = 0;
+ topLevelType < touchBank.length;
+ topLevelType++
+ )
+ if (
+ ((nativeEvent = touchBank[topLevelType]),
+ null != nativeEvent && nativeEvent.touchActive)
+ )
+ nativeEvent.touchActive = !1;
+ } else if (1 === touchHistory.numberActiveTouches) {
for (
topLevelType = 0;
topLevelType < touchBank.length;
@@ -16236,6 +16245,7 @@ __DEV__ &&
(null != topLevelType && topLevelType.touchActive) ||
console.error("Cannot find single active touch.");
}
+ }
},
touchHistory: touchHistory
},
@@ -16314,12 +16324,18 @@ __DEV__ &&
nativeEvent,
nativeEventTarget
) {
- if (isStartish(topLevelType)) trackedTouchCount += 1;
+ if (isStartish(topLevelType))
+ trackedTouchCount =
+ nativeEvent && Array.isArray(nativeEvent.touches)
+ ? nativeEvent.touches.length
+ : trackedTouchCount + 1;
else if (
"topTouchEnd" === topLevelType ||
"topTouchCancel" === topLevelType
)
- if (0 <= trackedTouchCount) --trackedTouchCount;
+ if (nativeEvent && Array.isArray(nativeEvent.touches))
+ trackedTouchCount = nativeEvent.touches.length;
+ else if (0 <= trackedTouchCount) --trackedTouchCount;
else
return (
console.warn(
diff --git a/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js b/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js
index 2625bf6..3d85e32 100644
--- a/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js
+++ b/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js
@@ -546,12 +546,21 @@ var instrumentationCallback,
else if (
"topTouchEnd" === topLevelType ||
"topTouchCancel" === topLevelType
- )
- if (
- (nativeEvent.changedTouches.forEach(recordTouchEnd),
- (touchHistory.numberActiveTouches = nativeEvent.touches.length),
- 1 === touchHistory.numberActiveTouches)
- )
+ ) {
+ nativeEvent.changedTouches.forEach(recordTouchEnd);
+ touchHistory.numberActiveTouches = nativeEvent.touches.length;
+ if (0 === touchHistory.numberActiveTouches) {
+ for (
+ topLevelType = 0;
+ topLevelType < touchBank.length;
+ topLevelType++
+ )
+ if (
+ ((nativeEvent = touchBank[topLevelType]),
+ null != nativeEvent && nativeEvent.touchActive)
+ )
+ nativeEvent.touchActive = !1;
+ } else if (1 === touchHistory.numberActiveTouches)
for (
topLevelType = 0;
topLevelType < touchBank.length;
@@ -564,6 +573,7 @@ var instrumentationCallback,
touchHistory.indexOfSingleActiveTouch = topLevelType;
break;
}
+ }
},
touchHistory: touchHistory
};
@@ -745,12 +755,18 @@ var ResponderEventPlugin = {
nativeEvent,
nativeEventTarget
) {
- if (isStartish(topLevelType)) trackedTouchCount += 1;
+ if (isStartish(topLevelType))
+ trackedTouchCount =
+ nativeEvent && Array.isArray(nativeEvent.touches)
+ ? nativeEvent.touches.length
+ : trackedTouchCount + 1;
else if (
"topTouchEnd" === topLevelType ||
"topTouchCancel" === topLevelType
)
- if (0 <= trackedTouchCount) --trackedTouchCount;
+ if (nativeEvent && Array.isArray(nativeEvent.touches))
+ trackedTouchCount = nativeEvent.touches.length;
+ else if (0 <= trackedTouchCount) --trackedTouchCount;
else return null;
ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
if (
diff --git a/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js b/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js
index 544c754..4d5ec08 100644
--- a/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js
+++ b/node_modules/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js
@@ -611,12 +611,21 @@ var instrumentationCallback,
else if (
"topTouchEnd" === topLevelType ||
"topTouchCancel" === topLevelType
- )
- if (
- (nativeEvent.changedTouches.forEach(recordTouchEnd),
- (touchHistory.numberActiveTouches = nativeEvent.touches.length),
- 1 === touchHistory.numberActiveTouches)
- )
+ ) {
+ nativeEvent.changedTouches.forEach(recordTouchEnd);
+ touchHistory.numberActiveTouches = nativeEvent.touches.length;
+ if (0 === touchHistory.numberActiveTouches) {
+ for (
+ topLevelType = 0;
+ topLevelType < touchBank.length;
+ topLevelType++
+ )
+ if (
+ ((nativeEvent = touchBank[topLevelType]),
+ null != nativeEvent && nativeEvent.touchActive)
+ )
+ nativeEvent.touchActive = !1;
+ } else if (1 === touchHistory.numberActiveTouches)
for (
topLevelType = 0;
topLevelType < touchBank.length;
@@ -629,6 +638,7 @@ var instrumentationCallback,
touchHistory.indexOfSingleActiveTouch = topLevelType;
break;
}
+ }
},
touchHistory: touchHistory
};
@@ -810,12 +820,18 @@ var ResponderEventPlugin = {
nativeEvent,
nativeEventTarget
) {
- if (isStartish(topLevelType)) trackedTouchCount += 1;
+ if (isStartish(topLevelType))
+ trackedTouchCount =
+ nativeEvent && Array.isArray(nativeEvent.touches)
+ ? nativeEvent.touches.length
+ : trackedTouchCount + 1;
else if (
"topTouchEnd" === topLevelType ||
"topTouchCancel" === topLevelType
)
- if (0 <= trackedTouchCount) --trackedTouchCount;
+ if (nativeEvent && Array.isArray(nativeEvent.touches))
+ trackedTouchCount = nativeEvent.touches.length;
+ else if (0 <= trackedTouchCount) --trackedTouchCount;
else return null;
ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
if (
diff --git a/node_modules/react-native/src/private/renderer/events/ReactNativeResponder.js b/node_modules/react-native/src/private/renderer/events/ReactNativeResponder.js
index da29336..7167a2f 100644
--- a/node_modules/react-native/src/private/renderer/events/ReactNativeResponder.js
+++ b/node_modules/react-native/src/private/renderer/events/ReactNativeResponder.js
@@ -560,9 +560,13 @@ export function processResponderEvent(
): void {
// Track touch count
if (isStartish(topLevelType)) {
- trackedTouchCount += 1;
+ trackedTouchCount = Array.isArray(nativeEvent.touches)
+ ? nativeEvent.touches.length
+ : trackedTouchCount + 1;
} else if (isEndish(topLevelType)) {
- if (trackedTouchCount >= 0) {
+ if (Array.isArray(nativeEvent.touches)) {
+ trackedTouchCount = nativeEvent.touches.length;
+ } else if (trackedTouchCount >= 0) {
trackedTouchCount -= 1;
} else {
if (__DEV__) {
diff --git a/node_modules/react-native/src/private/renderer/events/ResponderTouchHistoryStore.js b/node_modules/react-native/src/private/renderer/events/ResponderTouchHistoryStore.js
index c0b4d12..b4aab95 100644
--- a/node_modules/react-native/src/private/renderer/events/ResponderTouchHistoryStore.js
+++ b/node_modules/react-native/src/private/renderer/events/ResponderTouchHistoryStore.js
@@ -234,7 +234,14 @@ const ResponderTouchHistoryStore = {
} else if (isEndish(topLevelType)) {
nativeEvent.changedTouches.forEach(recordTouchEnd);
touchHistory.numberActiveTouches = nativeEvent.touches.length;
- if (touchHistory.numberActiveTouches === 1) {
+ if (touchHistory.numberActiveTouches === 0) {
+ for (let i = 0; i < touchBank.length; i++) {
+ const touchTrackToCheck = touchBank[i];
+ if (touchTrackToCheck != null && touchTrackToCheck.touchActive) {
+ touchTrackToCheck.touchActive = false;
+ }
+ }
+ } else if (touchHistory.numberActiveTouches === 1) {
for (let i = 0; i < touchBank.length; i++) {
const touchTrackToCheck = touchBank[i];
if (touchTrackToCheck != null && touchTrackToCheck.touchActive) {