Skip to content

Commit 30cc45c

Browse files
committed
Ensure bottom sheet is collapsed when leaving RTE mode. Closes #5635
1 parent 8149cc0 commit 30cc45c

File tree

1 file changed

+10
-5
lines changed
  • features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl

1 file changed

+10
-5
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.statusBars
2828
import androidx.compose.foundation.layout.systemBarsPadding
2929
import androidx.compose.material3.MaterialTheme
3030
import androidx.compose.runtime.Composable
31+
import androidx.compose.runtime.LaunchedEffect
3132
import androidx.compose.ui.Alignment
3233
import androidx.compose.ui.Modifier
3334
import 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

Comments
 (0)