Skip to content

Conversation

@tom-un
Copy link
Collaborator

@tom-un tom-un commented Jan 5, 2023

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

If the RCTRootView is not positioned at the origin of the NSWindow, then touch.pageX/pageY events will not have the correct coordinates. This can make it difficult for a user to click on Touchable and Pressable components unless there are no mouse moves between the mouse down and the mouse up events. The touch down and up events use the touch.locationX/locationY which are computed correctly, but after a touch down if the user move the mouse the touch.pageX/pageY coordinates are used and if the RCTRootView is not at the window origin, these coordinates will be offset. The result is the user will see touch feedback for a moment and then it disappears.

Changelog

[macOS] [Fixed] - Fix coordinates of touch.pageX/pageY coordinates when RCTRootView is not at the origin of the NSWindow

Test Plan

This issue only manifests if the RCTRootView is not at the origin of the NSWindow. To test this bug, I modified packages/rn-tester/RNTester-macOS/ViewController.m adding [rootView setFrameOrigin:(NSPoint){0,-100}]; at the end of viewDidLoad.

In the "Pressable" page, click on the first "Press Me" button and notice that it correctly changes to "Pressed!" back to "Press Me" if the mouse is dragged out of the Pressable.

This resolved #1618

tom-un and others added 30 commits April 3, 2020 20:53
Copy link
Collaborator

@Saadnajmi Saadnajmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Let me know if you need this merged if you don't have merge permissions. Also if it needs to be back ported.

@tom-un tom-un merged commit d7b689f into microsoft:main Jan 6, 2023
@tom-un
Copy link
Collaborator Author

tom-un commented Jan 6, 2023

Thanks @Saadnajmi ! Yes, this should be back ported to .68 -- the version currently deployed in Office, and any newer version that may be being prepared for deployment.

@Saadnajmi
Copy link
Collaborator

Thanks @Saadnajmi ! Yes, this should be back ported to .68 -- the version currently deployed in Office, and any newer version that may be being prepared for deployment.

We're currently doing the 71 merge on the main branch, so you should only need to make one more PR to 0.68-stable (we're skipping 0.69 and 0.70).

tom-un added a commit to tom-un/react-native that referenced this pull request Jan 6, 2023
…not at the origin of the NSWindow (microsoft#1619)

* Update scripts to publish react-native-macos-init

* Clean up merge markers

* Restored ios:macos RNTester parity except for InputAccessoryView.

* Revert "Restored ios:macos RNTester parity except for InputAccessoryView."

This reverts commit 5a67ae0.

* Remove unnecessary android builds and tar file upload.

* Fix coordinates of touch.pageX/pageY coordinates when RCTRootView is not at the origin of the NSWindow

Co-authored-by: React-Native Bot <53619745+rnbot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

touch.pageX/pageY coordinates are being computed incorrectly which can interfere with onPress events

3 participants