From 715fefe5a890fd7a2c028bb4cf0935ecf5d3e946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Tue, 6 Feb 2024 13:02:25 +0100 Subject: [PATCH] fix: properly retrieve window when clicking DevMenu action --- packages/react-native/React/CoreModules/RCTDevMenu.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-native/React/CoreModules/RCTDevMenu.mm b/packages/react-native/React/CoreModules/RCTDevMenu.mm index 1a970a7d086952..0bbe2b2a7eb685 100644 --- a/packages/react-native/React/CoreModules/RCTDevMenu.mm +++ b/packages/react-native/React/CoreModules/RCTDevMenu.mm @@ -409,9 +409,15 @@ - (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *__ { return ^(__unused UIAlertAction *action) { if (item) { +#if TARGET_OS_VISION + /// Execute this handler after the action sheet is dismissed to properly retrieve window when using SwiftUI entry point. + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0), dispatch_get_main_queue(), ^{ + [item callHandler]; + }); +#else [item callHandler]; +#endif } - self->_actionSheet = nil; }; }