Skip to content

Commit

Permalink
Fix buttons property value for non-hoverable pointers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vincentriemer authored and facebook-github-bot committed Aug 23, 2022
1 parent c4ddaa8 commit 32af9e6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion React/Fabric/RCTSurfaceTouchHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,16 @@ static PointerEvent CreatePointerEventFromActiveTouch(ActiveTouch activeTouch, R
event.button = activeTouch.button;
}

event.buttons = ButtonMaskToButtons(activeTouch.buttonMask);
event.buttons = 1;
if (@available(iOS 13.4, *)) {
if (activeTouch.touchType == UITouchTypeIndirectPointer) {
// Indirect pointers are the only situations where buttonMask is "accurate"
// so we override the assumed "left click" button value when those type of
// events are recieved
event.buttons = ButtonMaskToButtons(activeTouch.buttonMask);
}
}

UpdatePointerEventModifierFlags(event, activeTouch.modifierFlags);

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

0 comments on commit 32af9e6

Please sign in to comment.