Skip to content

Commit 5411eac

Browse files
fix(pointer): label a touch/pen contact as the primary button (#16338)
onPointerPressed maps ActiveTouch.button exclusively from PointerUpdateKind, a mouse-only concept. A touch or pen contact matches no case, falls through to default: button = -1, and the derived W3C buttons bitmask becomes 0. The pointerdown delivered to JS therefore claims no button is pressed, so pointer-event-driven press handling discards finger contacts while identical mouse clicks work. Per W3C pointer-events a touch/pen contact IS the primary button: button 0, buttons 1. Set that after the switch when the mouse mapping left it negative. main counterpart of the button-labeling change in #16333 (0.83-stable), tracking #16332. Ports only that change: main already covers the tag == -1 release leak and the stale-pointer-reuse leak via #16048 (dispatching a synthesized touch Cancel), and cancels capture loss per pointer. #16333's cancel-all loop, IsPrimary purge and stale-touch backstop are deliberately not ported - they do not exist on main and their necessity there has not been assessed.
1 parent eaf548c commit 5411eac

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix(fabric): dispatch touch/pen contacts with the W3C primary button (button 0, buttons 1) instead of button -1 / buttons 0, so pointer-event-driven press handling responds to finger taps the same as mouse left-clicks",
4+
"packageName": "react-native-windows",
5+
"email": "collindanielschneide@gmail.com",
6+
"dependentChangeType": "patch"
7+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,16 @@ void CompositionEventHandler::onPointerPressed(
14131413
break;
14141414
}
14151415

1416+
// A touch (or pen) contact has no mouse PointerUpdateKind, so it fell
1417+
// through to button = -1 — and the derived W3C buttons bitmask became 0.
1418+
// The dispatched pointerdown therefore told JS "no button is pressed", so
1419+
// press machinery driven by pointer events ignored finger taps while
1420+
// identical mouse clicks (button 0 / buttons 1) worked. Per W3C
1421+
// pointer-event semantics a touch/pen contact IS the primary button.
1422+
if (pointerPoint.PointerDeviceType() != Composition::Input::PointerDeviceType::Mouse && activeTouch.button < 0) {
1423+
activeTouch.button = 0;
1424+
}
1425+
14161426
while (targetComponentView) {
14171427
if (auto eventEmitter =
14181428
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(targetComponentView)

0 commit comments

Comments
 (0)