Skip to content

Commit 68debb2

Browse files
fkgozalimeta-codesync[bot]
authored andcommitted
Fix event timestamp injection to check both casing variants (facebook#56495)
Summary: Pull Request resolved: facebook#56495 UIManagerBinding::dispatchEvent checks for an existing timeStamp property before injecting one, but only checks the camelCase variant. Native events that use lowercase timestamp (e.g. pointer events) would have a duplicate timeStamp injected with the current time, which then takes precedence in the SyntheticEvent timestamp resolution chain (event.timeStamp || event.timestamp). This adds a check for both timeStamp and timestamp before auto-injecting, preserving the original native event timestamp when present in either casing. Root cause: facebook#55878 only checked for timeStamp (camelCase). Changelog: [General][Fixed] - Fix event timestamp injection overriding native timestamps with lowercase property name Reviewed By: mdvacca Differential Revision: D101522871 fbshipit-source-id: 74d91a3958ac73927251189f07f954303d45688e
1 parent 5620b1b commit 68debb2

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ 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")) {
150+
if (!payloadObject.hasProperty(runtime, "timeStamp") &&
151+
!payloadObject.hasProperty(runtime, "timestamp")) {
151152
payloadObject.setProperty(
152153
runtime, "timeStamp", eventTimestamp.toDOMHighResTimeStamp());
153154
}

0 commit comments

Comments
 (0)