From 5e6b69329481dcb7a6b76f4b0ef3f7fca9fced35 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 10 Jul 2026 12:39:02 +0300 Subject: [PATCH] Fix crash when maxHeight is nil at sheet presentation (#11104) Co-authored-by: Claude Fable 5 --- modules/bottom-sheet/ios/SheetView.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/bottom-sheet/ios/SheetView.swift b/modules/bottom-sheet/ios/SheetView.swift index 346fe3f413..1c6e963aa8 100644 --- a/modules/bottom-sheet/ios/SheetView.swift +++ b/modules/bottom-sheet/ios/SheetView.swift @@ -32,9 +32,12 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate { var cornerRadius: CGFloat? var sourceViewTag: Int? var minHeight = 0.0 - var maxHeight: CGFloat! { + // getScreenHeight() is nil when no window scene is connected yet (e.g. during + // prewarming or a background launch). A nil here previously trapped in + // clampHeight, so fall back to the full screen bounds instead. + var maxHeight: CGFloat = UIScreen.main.bounds.height { didSet { - let screenHeight = Util.getScreenHeight() ?? 0 + let screenHeight = Util.getScreenHeight() ?? UIScreen.main.bounds.height if maxHeight > screenHeight { maxHeight = screenHeight } @@ -77,7 +80,7 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate { required init (appContext: AppContext? = nil) { super.init(appContext: appContext) - self.maxHeight = Util.getScreenHeight() + self.maxHeight = Util.getScreenHeight() ?? UIScreen.main.bounds.height self.touchHandler = RCTTouchHandler(bridge: appContext?.reactBridge) SheetManager.shared.add(self) }