forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 151
feat: Add a dev menu to RCTSurfaceHostingView (2/2) #2749
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acoates-ms
approved these changes
Nov 5, 2025
62022f3 to
71b7b9e
Compare
71b7b9e to
df73d30
Compare
Saadnajmi
added a commit
that referenced
this pull request
Nov 5, 2025
## Summary: You can launch the dev menu 3 ways: 1. Via the hot key Cmd+D (not supported on macOS at time of writing, see notes for why) 2. Via a right click (not enabled in Fabric yet, see #2749) 3. By pressing "d" in a metro server This PR is focused on fixing issues with (3). When the dev menu was presented from metro, we didn't have a window or mouse location to key off of, so a context menu would present at coordinates (0,0), AKA, the bottom left of your screen on macOS. This isn't very discoverable or useful. To match other platforms, I think it would be better to make the dev menu an NSAlert, presented on top of the apps window. Let's also preserve the right click context menu for now, since that is still useful and muscle memory for most macOS devs. Let's also use some newer NSMenu APIs to set the title / subtitle while we're here. ## Test Plan: https://github.com/user-attachments/assets/64bc0bc1-c1b2-4b39-a0cb-def87baa91f2 ## Notes We don't want to support (1) because we don't want to register hotkeys on the window, a window may have multiple instances of RN running. We could register it on the root view... but on macOS, keyboard focus is rarely in the root view (it's usually just on the window or application) so this isn't very discoverable. I'll elect to skip implementing this flow for now.
df73d30 to
8fb86d4
Compare
Saadnajmi
commented
Nov 6, 2025
packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
You can launch the dev menu 3 ways:
This had a couple of problems:
We don't want to register hotkeys on the window, as a window may have multiple instances of RN running. We could register it on the root view. That may be hard to discover as keyboard focus is rarely in the root view for Mac apps... it's usually just on the window or applicatin.
The right click context menu wasn't available in Fabric, so this PR adds that. It involves a non trivial amount of code to add a contextContainer to RCTSurfaceHostingView and have RCTRootViewFactory set it.
The other issue is that when the menu is presented from metro, it's odd for it to be a context menu off the window or (if it can't find the window) at coordiantes 0,0 (bottom left of the screen for macOS). To match other platforms, I think it would be better to make the deve menu an NSAlert. Let's also preserve the right click context menu for now, since we don't have a way to get the dev menu from the app without metro otherwise.
Test Plan:
Dev menu on Fabric:
