Skip to content

Commit cd77f9c

Browse files
committed
Update CompositionEventHandler.cpp
1 parent 19fdef1 commit cd77f9c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,9 +1185,12 @@ void CompositionEventHandler::onPointerPressed(
11851185
});
11861186

11871187
if (staleTouch != m_activeTouches.end()) {
1188-
// A pointer with this ID already exists - Should we fire a button cancel or something?
1189-
// assert(false);
1190-
return;
1188+
// A previous pointer with this ID was never properly released (e.g., app lost focus,
1189+
// pointer left window). Cancel the stale touch and clean it up so the new press can proceed.
1190+
if (staleTouch->second.eventEmitter) {
1191+
DispatchTouchEvent(TouchEventType::Cancel, pointerId, pointerPoint, keyModifiers);
1192+
}
1193+
m_activeTouches.erase(staleTouch);
11911194
}
11921195

11931196
const auto eventType = TouchEventType::Start;
@@ -1246,6 +1249,12 @@ void CompositionEventHandler::onPointerPressed(
12461249
targetComponentView = targetComponentView.Parent();
12471250
}
12481251

1252+
// Don't register the touch if no eventEmitter was found — inserting a null-emitter entry
1253+
// into m_activeTouches would block future presses with the same pointer ID.
1254+
if (!activeTouch.eventEmitter) {
1255+
return;
1256+
}
1257+
12491258
UpdateActiveTouch(activeTouch, ptScaled, ptLocal);
12501259

12511260
// activeTouch.touch.isPrimary = true;

0 commit comments

Comments
 (0)