Yes, you’re probably using M3 bottom sheet? I fell into the same trap. Although we have the SheetState with
show()
and
hide()
, you also need to wrap the ModalBottomSheet in an
if
condition or it will always show and when you call
hide()
without the
if
condition, it will be invisible but still block any interaction with the UI. Also see the example code
here. Since I didn’t want to have an additional state I wrote an extension function for
SheetState
@ExperimentalMaterial3Api
val SheetState.shouldShowModalBottomSheet
get() = isVisible || targetValue == SheetValue.Expanded
and then I use it in Compose like
if (sheetState.shouldShowModalBottomSheet) {
ModalBottomSheet(
...
)
}