diff --git a/product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/ui/Web3ModalSheet.kt b/product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/ui/Web3ModalSheet.kt index 19d0335f5..3c01b3bb2 100644 --- a/product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/ui/Web3ModalSheet.kt +++ b/product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/ui/Web3ModalSheet.kt @@ -76,7 +76,18 @@ class Web3ModalSheet : BottomSheetDialogFragment() { modifier = Modifier.nestedScroll(rememberNestedScrollInteropConnection()), navController = navController, shouldOpenChooseNetwork = shouldOpenChooseNetwork, - closeModal = { this@Web3ModalSheet.dismiss() }) + closeModal = { + if (isAdded) { + if (!isStateSaved) { + this@Web3ModalSheet.dismiss() + } else { + Handler(Looper.getMainLooper()).post { + this@Web3ModalSheet.dismissAllowingStateLoss() + } + } + } + } + ) } }