Fix crash in TouchEvent when initialized with scroll MotionEvent action (#48723)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48723

## Changelog:
[Internal] -

In certain scenarios `TouchEvent` can be initialized with "unexpected" event actions, such as `ACTION_SCROLL`.

This caused an exception , even though such scenarios may be legitimate.

Reviewed By: javache

Differential Revision: D68265040

fbshipit-source-id: d31881e03d9110bb4f6af38548a4f73a41c54d2b
This commit is contained in:
Ruslan Shestopalyuk
2025-01-16 04:35:51 -08:00
committed by Facebook GitHub Bot
parent 0e6cb590ec
commit 918638c1be
@@ -64,7 +64,8 @@ public class TouchEvent private constructor() : Event<TouchEvent>() {
coalescingKey = touchEventCoalescingKeyHelper.getCoalescingKey(gestureStartTime)
MotionEvent.ACTION_CANCEL ->
touchEventCoalescingKeyHelper.removeCoalescingKey(gestureStartTime)
else -> throw RuntimeException("Unhandled MotionEvent action: $action")
else ->
Unit // Passthrough for other actions (such as ACTION_SCROLL), coalescing is not applied
}
motionEvent = MotionEvent.obtain(motionEventToCopy)