Skip to content
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

Don't recreate identical NSTrackingAreas #1971

Merged

Conversation

amgleitman
Copy link
Member

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:

We've seen an issue where mouse events sometimes behave strangely. The exact cause is unknown, but we found that one problem is that we're constantly recalculating the NSTrackingArea despite the fact that the size of the view isn't changing.

To resolve this, we limit the recreation of a new NSTrackingArea to when its size would actually change.

Changelog:

Pick one each for the category and type tags:

[MACOS] [FIXED] - Remove unnecessary recreation of NSTrackingAreas

Test Plan:

This was tested with the following test component in RNTester (not included as part of this change):

<View>
  <View
    width="20%"
    height={50}
    style={{backgroundColor: 'red'}}
    onMouseEnter={() => {
      console.log('onMouseEnter');
    }}
  />
</View>

I validated that the NSTrackingArea is correct by moving the mouse into the view from all four sides. This even holds between scrolls within RNTester, moving the window, and resizing the window. Furthermore, when resizing the window, -updateTrackingAreas only gets called once we release the mouse button and we finalize the new window size.

@Saadnajmi Saadnajmi merged commit 65fb4c0 into microsoft:main Nov 7, 2023
32 of 46 checks passed
@amgleitman amgleitman deleted the redundant-tracking-area-workaround branch November 7, 2023 07:33
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