From 03dad8418b6c4876bf7b817ace8a2ba8de361013 Mon Sep 17 00:00:00 2001 From: Tymoteusz Boba Date: Thu, 11 Apr 2024 09:55:27 +0200 Subject: [PATCH] fix(iOS): Change retrieving window in FullWindowOverlay (#2031) ## Description This PR is a follow up for the PR #1526. Currently, in React Native there's `RCTKeyWindow()` method which goes through each window of `RCTSharedApplication()` and selects the window that is a key window of a given window. This is a better solution, since we don't rely on a single `keyWindow` from RCTSharedApplication. I've also added a support for Fabric. I've checked how does FullWindowOverlay work with the change and it works as usual. Closes #1526. ## Changes - Changed the method of retrieving window from `delegate.window` to `RCTKeyWindow()` ## Test code and steps to reproduce You can run `Test1844` and check if FullWindowOverlay works correctly. ## Checklist - [X] Included code example that can be used to test this change - [X] Ensured that CI passes Co-authored-by: alexbumbu --- ios/RNSFullWindowOverlay.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RNSFullWindowOverlay.mm b/ios/RNSFullWindowOverlay.mm index 74f180423..ca1278a38 100644 --- a/ios/RNSFullWindowOverlay.mm +++ b/ios/RNSFullWindowOverlay.mm @@ -123,7 +123,7 @@ - (RNSFullWindowOverlayContainer *)container - (void)show { - UIWindow *window = RCTSharedApplication().delegate.window; + UIWindow *window = RCTKeyWindow(); [window addSubview:_container]; } @@ -156,7 +156,7 @@ - (void)didMoveToSuperview // so when the component gets recycled we need to add it back. - (void)maybeShow { - UIWindow *window = RCTSharedApplication().delegate.window; + UIWindow *window = RCTKeyWindow(); if (![[window subviews] containsObject:self]) { [window addSubview:_container]; }