From 918638c1beff405bfdbb5630f694ef8b45e365cd Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Thu, 16 Jan 2025 04:35:51 -0800 Subject: [PATCH] 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 --- .../java/com/facebook/react/uimanager/events/TouchEvent.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.kt index 0b763b702a3..0d003fd3d9a 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.kt @@ -64,7 +64,8 @@ public class TouchEvent private constructor() : Event() { 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)