|
16 | 16 |
|
17 | 17 | #if TARGET_OS_OSX && __has_include("RCTDevMenu.h") // [macOS |
18 | 18 | #import "RCTDevMenu.h" |
19 | | -#import "RCTBridgeProxy.h" |
20 | 19 | #import <react/utils/ManagedObjectWrapper.h> |
21 | 20 | #endif // macOS] |
22 | 21 |
|
@@ -299,45 +298,26 @@ - (void)surface:(__unused RCTSurface *)surface didChangeIntrinsicSize:(__unused |
299 | 298 | }); |
300 | 299 | } |
301 | 300 |
|
302 | | -#if TARGET_OS_OSX // [macOS] |
| 301 | +#if TARGET_OS_OSX // [macOS |
303 | 302 |
|
304 | 303 | #pragma mark - Context Menu |
305 | 304 |
|
306 | 305 | - (NSMenu *)menuForEvent:(NSEvent *)event |
307 | 306 | { |
308 | | - NSMenu *menu = nil; |
309 | | - |
310 | | -#if __has_include("RCTDevMenu.h") && RCT_DEV |
311 | | - // Try to get dev menu from context container |
| 307 | +#if RCT_DEV_MENU && __has_include("RCTDevMenu.h") |
312 | 308 | if (_contextContainer) { |
313 | 309 | auto devMenuOptional = _contextContainer->find<std::shared_ptr<void>>("RCTDevMenu"); |
314 | 310 | if (devMenuOptional.has_value()) { |
315 | | - RCTDevMenu *devMenu = unwrapManagedObject(*devMenuOptional); |
316 | | - if (devMenu && [devMenu respondsToSelector:@selector(menu)]) { |
317 | | - menu = [devMenu menu]; |
318 | | - } |
319 | | - } |
320 | | - } |
321 | | - |
322 | | - // Fallback: try legacy bridge access if surface has bridge |
323 | | - if (menu == nil && [_surface respondsToSelector:@selector(bridge)]) { |
324 | | - RCTBridge *bridge = [_surface performSelector:@selector(bridge)]; |
325 | | - if (bridge && [bridge respondsToSelector:@selector(devMenu)]) { |
326 | | - RCTDevMenu *devMenu = [bridge devMenu]; |
327 | | - if (devMenu && [devMenu respondsToSelector:@selector(menu)]) { |
328 | | - menu = [devMenu menu]; |
| 311 | + RCTDevMenu *devMenu = facebook::react::unwrapManagedObject(*devMenuOptional); |
| 312 | + if (devMenu) { |
| 313 | + return [devMenu menu]; |
329 | 314 | } |
330 | 315 | } |
331 | 316 | } |
332 | 317 | #endif |
333 | | - |
334 | | - // Fall back to super's menu if no dev menu available |
335 | | - if (menu == nil) { |
336 | | - menu = [super menuForEvent:event]; |
337 | | - } |
338 | | - |
339 | | - return menu; |
| 318 | + |
| 319 | + return [super menuForEvent:event]; |
340 | 320 | } |
341 | | -#endif // [macOS] |
| 321 | +#endif // macOS] |
342 | 322 |
|
343 | 323 | @end |
0 commit comments