Status Update
Comments
so...@google.com <so...@google.com> #2
If a bottom sheet is in a half expanded state and recreated into a screen where half expanded isn't possible (because it isn't tall enough) it crashes with the same error.
This is also an issue in pre 1.4.0-alpha04, but the error message is "The initial value must have an associated anchor".
This is easily reproducible by having a bottom sheet with a height that in landscape has half expanded, but doesn't in portrait. When rotating with the sheet open it always crashes. This can be mitigated by disallowing the bottom sheet to be half expanded by creating the bottom sheet state with rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden, skipHalfExpanded = true)
ni...@google.com <ni...@google.com> #3
Thanks for the report. Do you have an isolated repro?
nj...@google.com <nj...@google.com>
se...@gmail.com <se...@gmail.com> #4
You do - apologies, I missed that. We'll check it out! :)
di...@gal-digital.de <di...@gal-digital.de> #5
Looked into this - I believe it is due to how we require the previous target's offset in the anchor change
handler. When animating to a target, we will always update the currentValue
, regardless of whether it exists in the anchors. This is useful for specifically your use case where you call animateTo
(through show
) before the sheet content is recomposed and re-measured. The anchor change handler can move to the appropriate target when the anchors change after the layout size changes.
Instead of requiring the previous target's offset - since it might not be in the anchors - we will change this to a nullable getter in the change handler.
As a workaround, you can place the call in an effect - this should make sure things are executed at the right time. This code from your repro:
ModalBottomSheetLayout(
sheetState = bottomSheetState,
sheetBackgroundColor = if (showSheetContent) Color.Red else Color.Transparent,
scrimColor = if (showSheetContent) ModalBottomSheetDefaults.scrimColor else Color.Transparent,
sheetContent = {
if (showSheetContent) {
SheetContent()
}
}
) {
Column {
Button(
onClick = {
showSheetContent = true
coroutineScope.launch {
bottomSheetState.show()
}
}
) { ... }
}
}
Would become:
if (showSheetContent) {
LaunchedEffect(Unit) {
bottomSheetState.show()
}
}
ModalBottomSheetLayout(
sheetState = bottomSheetState,
sheetBackgroundColor = if (showSheetContent) Color.Red else Color.Transparent,
scrimColor = if (showSheetContent) ModalBottomSheetDefaults.scrimColor else Color.Transparent,
sheetContent = {
if (showSheetContent) {
SheetContent()
}
}
) {
Column {
Button(
onClick = {
showSheetContent = true
}
) { ... }
}
We'll update this issue once we merge the fix.
ap...@google.com <ap...@google.com> #6
I'll add that the bottom sheet "floats" above the bottom of the screen
Would you mind filing a separate issue for this? I wasn't able to reproduce it yet.
Description
This is recurrent question from several developers as you can see below...
The answer is always the same: "Use BasicTexfield". But we want everything from the Material TextField except the padding?
Could you please provide a way to set this padding? (see image attached)