Skip to content

Commit cf86071

Browse files
committed
fix(android): dismiss sheet early when container is unmounted
1 parent 16e96d7 commit cf86071

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
135135
val child = getChildAt(index)
136136
if (child is TrueSheetContainerView) {
137137
child.delegate = null
138+
139+
// Dismiss the sheet when container is removed
140+
if (viewController.isPresented) {
141+
viewController.dismiss(animated = false)
142+
}
138143
}
139144
viewController.removeView(child)
140145
}
@@ -159,14 +164,12 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
159164
fun onDropInstance() {
160165
reactContext.removeLifecycleEventListener(this)
161166

162-
if (viewController.isPresented) {
163-
viewController.dismiss(animated = false)
164-
}
167+
viewController.dismiss()
168+
viewController.delegate = null
165169

166170
TrueSheetModule.unregisterView(id)
167171
TrueSheetStackManager.removeSheet(this)
168172

169-
viewController.delegate = null
170173
didInitiallyPresent = false
171174
}
172175

0 commit comments

Comments
 (0)