From 30d39a32909f4b4ed3edee753cdd8993af273d17 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 10 Nov 2025 16:59:36 +0100 Subject: [PATCH] Ensure bottom sheet is collapsed when leaving RTE mode. Closes #5635 --- .../features/messages/impl/MessagesView.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt index 4f18421679..1f62adeb23 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt @@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow @@ -278,14 +279,13 @@ fun MessagesView( }, ) }, - sheetDragHandle = if (state.composerState.showTextFormatting) { - @Composable { toggleAction -> + sheetDragHandle = @Composable { toggleAction -> + if (state.composerState.showTextFormatting) { val expandA11yLabel = stringResource(CommonStrings.a11y_expand_message_text_field) val collapseA11yLabel = stringResource(CommonStrings.a11y_collapse_message_text_field) BottomSheetDragHandle( modifier = Modifier.semantics { role = Role.Button - // Accessibility action to toggle the bottom sheet state val label = when (expandableState.position) { ExpandableBottomSheetLayoutState.Position.COLLAPSED, ExpandableBottomSheetLayoutState.Position.DRAGGING -> expandA11yLabel @@ -297,9 +297,14 @@ fun MessagesView( } } ) + } else { + LaunchedEffect(Unit) { + // Ensure that the bottom sheet is collapsed + if (expandableState.position == ExpandableBottomSheetLayoutState.Position.EXPANDED) { + toggleAction() + } + } } - } else { - @Composable {} }, isSwipeGestureEnabled = state.composerState.showTextFormatting, state = expandableState,