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

Send JS blur/focus events when switching to another NSWindow #2323

Merged

Conversation

amgleitman
Copy link
Member

Summary:

Consider a React Native experience occurring inside an NSPanel. On macOS, this NSPanel will keep track of its own first responder. In other words, if you click off that panel and into somewhere else (be it another NSWindow in the same app or another app altogether), the NSPanel never relinquishes its first responder, so we never send the blur or focus events to the JS side.

In this example of blur and focus events in Web, we see that the blur and focus events still take effect when switching windows. Therefore, it's reasonable to try to do the same in react-native-macos. We only send the events at the JS level; as far as the OS is concerned, we leave the first responders themselves intact.

Test Plan:

This was tested with the help of react-native-test-app. Specifically, I added a React Native experience hosted in an NSPanel and added some <Pressable> elements with onBlur and onFocus events. Upon switching windows, we do indeed see the blur and focus events coming through, and each NSWindow properly maintains its own first responder as desired.

@amgleitman amgleitman requested a review from a team as a code owner December 27, 2024 01:53
@amgleitman amgleitman merged commit bb79721 into microsoft:main Dec 27, 2024
14 checks passed
amgleitman pushed a commit to amgleitman/react-native-macos that referenced this pull request Dec 27, 2024
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.

3 participants