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

[Pressable] Mouse drags inside Pressable don't move the window #1857

Merged
merged 5 commits into from
Jun 21, 2023

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Jun 20, 2023

WIP, there's still some test code laying around.

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

When you host RN inside a window with a movable background, we don't want clicks inside Buttons/Controls/Pressables to move the window. We instead want to be able to click and drag off the Button to "cancel" the mouse interaction.This matches native Appkit controls. There's a convenient prop on NSView to do this, mouseDownCanMoveWindow, let's just expose it to React Native and set it to false on Pressable (the closest thing we have to an NSControl subclass in JS land).

Changelog

[MACOS] [FIXED] - Mouse drags inside Pressable don't move the window

Test Plan

Made RNTester's window movable via [self.window setMovableByWindowBackground:YES]; inside AppDelegate.mm. I then tested dragging the window from inside and outside a Pressable. I compared this to the behavior of dragging NSSwitch (one of the native controls exposed by RN).

Screen.Recording.2023-06-20.at.10.58.04.AM.mov

@Saadnajmi Saadnajmi requested a review from a team as a code owner June 20, 2023 17:58
@Saadnajmi Saadnajmi marked this pull request as draft June 20, 2023 18:03
@Saadnajmi Saadnajmi marked this pull request as ready for review June 20, 2023 18:58
@Saadnajmi Saadnajmi merged commit 11d573f into microsoft:main Jun 21, 2023
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