Skip to content

Commit cf1975f

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Remove lowercase timestamp fallback in event timestamp injection (#56512)
Summary: Pull Request resolved: #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
1 parent 70281d6 commit cf1975f

2 files changed

Lines changed: 1 addition & 34 deletions

File tree

packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ void UIManagerBinding::dispatchEventToJS(
147147
// Add timestamp to payload if not already set
148148
if (payload.isObject()) {
149149
auto payloadObject = payload.asObject(runtime);
150-
if (!payloadObject.hasProperty(runtime, "timeStamp") &&
151-
!payloadObject.hasProperty(runtime, "timestamp")) {
150+
if (!payloadObject.hasProperty(runtime, "timeStamp")) {
152151
payloadObject.setProperty(
153152
runtime, "timeStamp", eventTimestamp.toDOMHighResTimeStamp());
154153
}

packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,6 @@ describe('Event Dispatching', () => {
5555
);
5656
});
5757

58-
it('provides the native event timestamp (lower case) when available', () => {
59-
const root = Fantom.createRoot();
60-
61-
const ref = React.createRef<React.ElementRef<typeof View>>();
62-
63-
const onPointerUp = jest.fn((e: PointerEvent) => {
64-
e.persist();
65-
});
66-
67-
Fantom.runTask(() => {
68-
root.render(<View ref={ref} onPointerUp={onPointerUp} />);
69-
});
70-
71-
expect(onPointerUp).toHaveBeenCalledTimes(0);
72-
73-
const NATIVE_EVENT_TIMESTAMP = 1234;
74-
75-
Fantom.dispatchNativeEvent(
76-
ref,
77-
'onPointerUp',
78-
{x: 0, y: 0, timestamp: NATIVE_EVENT_TIMESTAMP},
79-
{
80-
category: Fantom.NativeEventCategory.Discrete,
81-
},
82-
);
83-
84-
expect(onPointerUp).toHaveBeenCalledTimes(1);
85-
expect(onPointerUp.mock.calls[0][0].timeStamp).toBe(
86-
NATIVE_EVENT_TIMESTAMP,
87-
);
88-
});
89-
9058
it('provides a default timeStamp when the native event timeStamp is NOT available', () => {
9159
const root = Fantom.createRoot();
9260

0 commit comments

Comments
 (0)