hey, I’m having an issue with a `BottomSheet` that...
# compose
o
hey, I’m having an issue with a
BottomSheet
that has a list of items to show, the list comes from a
MVI ViewModel
the issue is the bottomsheet is not showing,
viewState.items
returns an empty list as initial state before getting the real list with n items -if I hardcode the list to a list initially it’s fine -if I give the
Column
a specific height it’s fine not sure why it doesn’t show when the list is dynamic, any tips? does the bottomsheet have problems showing if the content height is changing when the height is undefined?
Copy code
@Composable
fun BottomSheetContent(
    viewModel: ItemViewModel = getViewModel()
) {
    val viewState: ItemViewState by viewModel.viewState.collectAsStateLifecycleAware()
    // vm intent call

    BottomSheetScreen(items = viewState.items)
}
Copy code
@Composable
private fun BottomSheetScreen(items: List<Item>) {
    Column(modifier = Modifier.fillMaxWidth()) { //.height(150.dp) works
        SheetHeader(title = "title")

        items.forEach { item ->
            ItemContent(item)
        }
    }
}
to clarify the bottomsheet is added from NavHost
Copy code
addDestination(
    BottomSheetNavigator.Destination(
        provider[BottomSheetNavigator::class],
        content
    ).apply {
        this.route = navigationEvent.route
    }
)
d
How is the list defined and updated?
i
What version of Compose are you using? Compose Material 1.4.0-alpha04 had a huge refactoring of the internals of how bottom sheets work specifically to fix issues like this
o
@dorche it’s a flow collected as state, and just updates whenever the vm has new data
@Ian Lake thanks for the info! definitely using an earlier version, will update and check
j
Yep, the newer alphas should fix this :)