@@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.statusBars
2828import androidx.compose.foundation.layout.systemBarsPadding
2929import androidx.compose.material3.MaterialTheme
3030import androidx.compose.runtime.Composable
31+ import androidx.compose.runtime.LaunchedEffect
3132import androidx.compose.ui.Alignment
3233import androidx.compose.ui.Modifier
3334import androidx.compose.ui.draw.shadow
@@ -278,14 +279,13 @@ fun MessagesView(
278279 },
279280 )
280281 },
281- sheetDragHandle = if (state.composerState.showTextFormatting) {
282- @Composable { toggleAction ->
282+ sheetDragHandle = @Composable { toggleAction ->
283+ if (state.composerState.showTextFormatting) {
283284 val expandA11yLabel = stringResource(CommonStrings .a11y_expand_message_text_field)
284285 val collapseA11yLabel = stringResource(CommonStrings .a11y_collapse_message_text_field)
285286 BottomSheetDragHandle (
286287 modifier = Modifier .semantics {
287288 role = Role .Button
288-
289289 // Accessibility action to toggle the bottom sheet state
290290 val label = when (expandableState.position) {
291291 ExpandableBottomSheetLayoutState .Position .COLLAPSED , ExpandableBottomSheetLayoutState .Position .DRAGGING -> expandA11yLabel
@@ -297,9 +297,14 @@ fun MessagesView(
297297 }
298298 }
299299 )
300+ } else {
301+ LaunchedEffect (Unit ) {
302+ // Ensure that the bottom sheet is collapsed
303+ if (expandableState.position == ExpandableBottomSheetLayoutState .Position .EXPANDED ) {
304+ toggleAction()
305+ }
306+ }
300307 }
301- } else {
302- @Composable {}
303308 },
304309 isSwipeGestureEnabled = state.composerState.showTextFormatting,
305310 state = expandableState,
0 commit comments