You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ios): render dim in presenter view when presenter VC is detached
When TrueSheet is presented from a UIViewController that is not reachable
from the key window's root VC via the parent/presentingViewController
chain, UIKit's built-in UISheetPresentationController dim layer lands in
the wrong UIWindow — the sheet content renders correctly but the dim
appears in a fallback container instead of behind the sheet.
iOS surfaces this at runtime as:
"Presenting view controller ... from detached view controller ... is
not supported, and may result in incorrect safe area insets and a
corrupt root presentation."
Detachment is inherited up the chain: a VC can have a non-nil
presentingViewController but still be detached if that presenter is
itself detached. A single-level check is not sufficient.
Two changes:
1. findPresentingViewController walks superview.nextResponder to locate
the nearest ancestor VC. This correctly finds VCs parked in the view
tree by custom navigators (which may use addSubview: rather than
modal presentation), where the previous window.rootViewController
presentedViewController chain walk would miss them.
2. Added isPresenterDetached: which walks parent/presenting chain until
it reaches the window's root VC. When the presenter is detached AND
dimmed is YES, we add a fallback dim UIView as a subview of the
presenter's view so it lives in the correct window below the
natively-presented sheet. The dim is removed (animated) in
dismissAnimated:, viewControllerWillDismiss, prepareForRecycle, and
dealloc so every dismissal path — including swipe-dismiss and Fabric
view recycling — cleans up correctly.
No behavior change for the attached-presenter path.
Closes#661
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
5
5
### 🐛 Bug fixes
6
6
7
+
-**iOS**: Fixed sheet dim rendering in the wrong `UIWindow` when the presenter view controller is detached from the window's VC hierarchy (e.g. inside a custom navigator or RN `<Modal>`). `findPresentingViewController` now walks the responder chain to find the real owning VC, and a fallback dim view is added to the presenter's view when the presenter is detached. ([#TBD](https://github.com/lodev09/react-native-true-sheet/pull/TBD) by [@kanzelm3](https://github.com/kanzelm3))
7
8
-**Android**: Fixed focused input in sheet causing auto-focus on main screen input after dismiss. ([#649](https://github.com/lodev09/react-native-true-sheet/pull/649) by [@lodev09](https://github.com/lodev09))
0 commit comments