Commit fda2587
authored
feat: Add a dev menu to RCTSurfaceHostingView (2/2) (#2749)
## 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:
<img width="627" height="896" alt="image"
src="https://github.com/user-attachments/assets/50a25f80-db10-4ca3-bbcf-44165d2f4ce8"
/>1 parent b3aad0b commit fda2587
File tree
4 files changed
+60
-3
lines changed- packages/react-native
- Libraries/AppDelegate
- React/Base
- Surface/SurfaceHostingView
4 files changed
+60
-3
lines changedLines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
| |||
183 | 195 | | |
184 | 196 | | |
185 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
186 | 208 | | |
187 | 209 | | |
188 | 210 | | |
| |||
327 | 349 | | |
328 | 350 | | |
329 | 351 | | |
330 | | - | |
| 352 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
| 497 | + | |
498 | 498 | | |
499 | | - | |
| 499 | + | |
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
66 | 77 | | |
67 | 78 | | |
68 | 79 | | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
| |||
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| |||
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
281 | 305 | | |
0 commit comments