Skip to content

Back port 1619 and 1288 to 0.68: Fix coordinates of touch.pageX/pageY coordinates when RCTRootView is not at the origin of the NSWindow #1627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

tom-un
Copy link
Collaborator

@tom-un tom-un commented Jan 8, 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

This is a back port of the recent change to master: 1619 Fix coordinates of touch.pageX/pageY coordinates when RCTRootView is not at the origin of the NSWindow.

The change touches the same code where a similar fix for touch.locationX/locationY: 1288 Fix event.locationX/Y to be in view's coordinate space

Both changes are back ported in this change.

f 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] [Fix] - Back port 1619 to 0.68: 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. The various Touchable pages and other pages were tested

tom-un and others added 2 commits January 6, 2023 17:38
…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 <[email protected]>
@tom-un tom-un requested a review from a team as a code owner January 8, 2023 18:48
@Saadnajmi Saadnajmi merged commit 0b969bb into microsoft:0.68-stable Jan 8, 2023
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
…gexy-coordinates

Back port 1619 and 1288 to 0.68: Fix coordinates of touch.pageX/pageY coordinates when RCTRootView is not at the origin of the NSWindow
# Conflicts:
#	React/Base/RCTTouchHandler.m
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.

2 participants