Skip to content

Commit 32af9e6

Browse files
vincentriemerfacebook-github-bot
authored andcommitted
Fix buttons property value for non-hoverable pointers
Summary: Changelog: [iOS][Internal] - Fix buttons property value for non-hoverable pointers The previous diff ensured that on iOS you could run through the entirety of the non-hoverable pointer event attributes test but that also revealed some failing tests related to the `buttons` property when using a non-hoverable pointer. This diff fixes that by ensuring that we only forward the result of the `buttonMask` to `buttons` when the pointer is a mouse, and assume that it is an emulated left click otherwise. Reviewed By: lunaleaps Differential Revision: D38914239 fbshipit-source-id: c573e934d0e9c0ac2af4945dc5360840ddc87d4d
1 parent c4ddaa8 commit 32af9e6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

React/Fabric/RCTSurfaceTouchHandler.mm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,16 @@ static PointerEvent CreatePointerEventFromActiveTouch(ActiveTouch activeTouch, R
349349
event.button = activeTouch.button;
350350
}
351351

352-
event.buttons = ButtonMaskToButtons(activeTouch.buttonMask);
352+
event.buttons = 1;
353+
if (@available(iOS 13.4, *)) {
354+
if (activeTouch.touchType == UITouchTypeIndirectPointer) {
355+
// Indirect pointers are the only situations where buttonMask is "accurate"
356+
// so we override the assumed "left click" button value when those type of
357+
// events are recieved
358+
event.buttons = ButtonMaskToButtons(activeTouch.buttonMask);
359+
}
360+
}
361+
353362
UpdatePointerEventModifierFlags(event, activeTouch.modifierFlags);
354363

355364
// UIEvent's button mask for touch end events still marks the button as down

0 commit comments

Comments
 (0)