I have a problem with the `BottomSheetScaffold` th...
# compose
d
I have a problem with the
BottomSheetScaffold
the bottom sheet keeps expanding. It seems like no matter what I do it just keeps popping open. Has anybody else run into this problem?
s
Ran into the same issue last week. Got a little busy over the week so I'll post my snippet here tomorrow (its midnight here). Basically it keeps going to the expanded state even if I drag the sheet down to its original state.
same 1
d
Even if I call
collapse()
it just pops open again.
This doesn’t even work:
Copy code
val bottomSheetState = rememberBottomSheetState(
        initialValue = initialSheetState,
        confirmStateChange = {
            when (it) {
                Collapsed -> {
                    true
                }
                Expanded -> {
                    false
                }
            }
        }
    )
m
Thanks for raising this folks. I have troubles to reproduce this issue. Please ,file a bug if you can with the code snippets attached if possible, thanks
d
@matvei I found this in the BottomDrawer implementation code:
Copy code
if (drawerState.isOpen) {
    // TODO(b/180101663) The action currently doesn't return the correct results
    dismiss(action = { scope.launch { drawerState.close() }; true })
}
This todo is probably a high priority one or should be lol.
m
@dewildte Thanks for bringing this up. Could you please elaborate on what makes you think it should be a high priority? Ar you facing some issue with this logic?
d
The drawer does not close. So the entire component is rendered useless.
Seriously
m
Not sure I follow. Do you face issues with accessibility services with BottomDrawer? The TODO you listed above is for accessibility action to close the drawer when accessibility users desires so. It closes regardless of the value, it just won't report back when the closure is failed (due to interruption for example). I'm not sure accessibility services are able to process this info properly, but this particular todo has nothing connected with the gestures/programmatic opening of the drawer.
d
Oh, I think I miss-understood the TODO then. The problem is that the BottomSheet in the BottomSheetScaffold never stays closed.
This makes using the entire component impossible.
m
Sorry, as per my first message in this thread, I still don't understand what doesn't work. If by "closed" you mean "not on the screen", then it's by design. BottomSheetScaffold's bottom sheet is not intended to be closed completely. It's be the material specs it implements. https://material.io/components/sheets-bottom#standard-bottom-sheet If you need a contextual bottom sheet that can be contextually shown and closed, there'a a ModalBottomSheetLayout for that, which implements modal bottom sheet specs. https://material.io/components/sheets-bottom#modal-bottom-sheet
d
Anytime you change its state from Expanded, it automatically changes back to Expanded no matter what you do.
m
If you have a snippet that doesn't work for you -- please free to file a bug with the snippet and other relevant details attached
d
@matvei Please try this code. I suspect it has to do with the fact that internally it responds to peekHeight changes and then gets stuck in some kind of loop.