Skip to content

Conversation

@Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented 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)
  2. Via a right click (which wasn't enabled in Fabric yet)
  3. By pressing "d" in metro.

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:
image

@Saadnajmi Saadnajmi force-pushed the alert-devmenu branch 2 times, most recently from 62022f3 to 71b7b9e Compare November 5, 2025 21:34
@Saadnajmi Saadnajmi changed the title feat(dev menu): Bring right click dev menu to Fabric, make a new NSAlert style dev menu feat: Add a dev menu to RCTSurfaceHostingView via a ContextContainer (2/2) Nov 5, 2025
@Saadnajmi Saadnajmi marked this pull request as ready for review November 5, 2025 21:35
@Saadnajmi Saadnajmi requested a review from a team as a code owner November 5, 2025 21:35
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.
@Saadnajmi Saadnajmi changed the title feat: Add a dev menu to RCTSurfaceHostingView via a ContextContainer (2/2) feat: Add a dev menu to RCTSurfaceHostingView (2/2) Nov 6, 2025
@Saadnajmi Saadnajmi merged commit fda2587 into microsoft:main Nov 7, 2025
21 checks passed
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