From cf1975f1c38c06a1ed3df59c3f6d78aae7904f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Tue, 21 Apr 2026 04:44:56 -0700 Subject: [PATCH] Remove lowercase `timestamp` fallback in event timestamp injection (#56512) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56512 Changelog: [internal] `UIManagerBinding::dispatchEvent` injects a `timeStamp` property into the event payload when one is not already present. A previous change extended this check to also skip injection when a lowercase `timestamp` property was present, so that native events using the lowercase form would have their timestamp preserved. That was done to fix a failing Fantom test but what was wrong was the test itself. This removes the test and reverts that previous fix. Reviewed By: javache Differential Revision: D101649991 fbshipit-source-id: 933c906403f2e4144575b89e11f96feb8775f455 --- .../renderer/uimanager/UIManagerBinding.cpp | 3 +- .../core/__tests__/EventDispatching-itest.js | 32 ------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index 47ea058bcf2..c79fc75df5b 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -147,8 +147,7 @@ void UIManagerBinding::dispatchEventToJS( // Add timestamp to payload if not already set if (payload.isObject()) { auto payloadObject = payload.asObject(runtime); - if (!payloadObject.hasProperty(runtime, "timeStamp") && - !payloadObject.hasProperty(runtime, "timestamp")) { + if (!payloadObject.hasProperty(runtime, "timeStamp")) { payloadObject.setProperty( runtime, "timeStamp", eventTimestamp.toDOMHighResTimeStamp()); } diff --git a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js index bb95eab0c05..eec975e6217 100644 --- a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js +++ b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js @@ -55,38 +55,6 @@ describe('Event Dispatching', () => { ); }); - it('provides the native event timestamp (lower case) when available', () => { - const root = Fantom.createRoot(); - - const ref = React.createRef>(); - - const onPointerUp = jest.fn((e: PointerEvent) => { - e.persist(); - }); - - Fantom.runTask(() => { - root.render(); - }); - - expect(onPointerUp).toHaveBeenCalledTimes(0); - - const NATIVE_EVENT_TIMESTAMP = 1234; - - Fantom.dispatchNativeEvent( - ref, - 'onPointerUp', - {x: 0, y: 0, timestamp: NATIVE_EVENT_TIMESTAMP}, - { - category: Fantom.NativeEventCategory.Discrete, - }, - ); - - expect(onPointerUp).toHaveBeenCalledTimes(1); - expect(onPointerUp.mock.calls[0][0].timeStamp).toBe( - NATIVE_EVENT_TIMESTAMP, - ); - }); - it('provides a default timeStamp when the native event timeStamp is NOT available', () => { const root = Fantom.createRoot();