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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please select one of the following
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 theNSWindow
, thentouch.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 thetouch.locationX/locationY
which are computed correctly, but after a touch down if the user move the mouse thetouch.pageX/pageY
coordinates are used and if theRCTRootView
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 theNSWindow
. To test this bug, I modifiedpackages/rn-tester/RNTester-macOS/ViewController.m
adding[rootView setFrameOrigin:(NSPoint){0,-100}];
at the end ofviewDidLoad
.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