From d0efab0798abe62fd667bcc407dec8e87fccd063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nishan=20=28o=5E=E2=96=BD=5Eo=29?= Date: Mon, 21 Aug 2023 17:01:39 +0530 Subject: [PATCH] fix: full window overlay cannot receive tap when modal is full screen (#1872) ## Description - `FullWindowOverlay` cannot receive tap events when it is shown on top of `UIModalPresentationFullScreen` Modal which is the default presentation style of the react native Modal. - UIKit changes the layout hierarchy when the modal is full screen. It is mentioned in the below docs. The view does not move to the window if a full-screen modal is being presented. However, the `_container` moves to the window as it is appended explicitly using `addSubview` in the key window. - https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html Screenshot 2023-08-21 at 9 45 19 AM - So the `RNSFullWindowOverlay` view gets attached to the superview but they are not moved to the window. This PR adds a simple fix to replace `didMoveToWindow` with `didMoveToSuperview`. I considered an approach to move `didMoveToWindow` in the `RNSFullWindowOverlayContainer` but I don't see any potential issues with the current approach. Let me know. ## Changes Attach touch handlers to the container in `didMoveToSuperview` instead of `didMoveToWindow` ## Test code and steps to reproduce Run the below snack on iOS. - https://snack.expo.dev/@nishanbende/fullwindowoverlay-tap-events-on-full-screen-modal ## Checklist - [x] Included code example that can be used to test this change - [x] Updated TS types - [x] Updated documentation: - [x] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [x] Ensured that CI passes --- ios/RNSFullWindowOverlay.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RNSFullWindowOverlay.mm b/ios/RNSFullWindowOverlay.mm index 101cacecf8..74f1804239 100644 --- a/ios/RNSFullWindowOverlay.mm +++ b/ios/RNSFullWindowOverlay.mm @@ -127,9 +127,9 @@ - (void)show [window addSubview:_container]; } -- (void)didMoveToWindow +- (void)didMoveToSuperview { - if (self.window == nil) { + if (self.superview == nil) { if (_container != nil) { [_container removeFromSuperview]; [_touchHandler detachFromView:_container];