Skip to content

Commit 82ee330

Browse files
committed
Prevent accidental sheet dismissal via drag handle area
Material3 wraps the composable passed to ModalBottomSheet's dragHandle slot in a Modifier.clickable that dismisses an expanded sheet. That clickable is not covered by sheetGesturesEnabled, so tapping the empty space of the header (next to the menu actions) closed sheets that explicitly disabled gestures - Add Principal, Create Calendar, Update Principal Password and Settings. When gestures are disabled, render the header as ordinary sheet content and pass no drag handle at all. The sheet then only closes through its menu actions or by clicking the scrim outside of it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ACWMSLHFXaEukqSo5KyAF8
1 parent 7e39f21 commit 82ee330

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

shared/src/commonMain/kotlin/at/techbee/spectacled/screens/core/presentation/components/BottomSheetWithMenu.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,17 @@ fun BottomSheetWithMenu(
8181
ModalBottomSheet(
8282
onDismissRequest = { onDismiss() },
8383
sheetState = sheetState,
84-
dragHandle = header,
84+
// Material3 wraps whatever is passed as dragHandle in a clickable that dismisses an
85+
// expanded sheet - and that clickable is not covered by sheetGesturesEnabled. So when
86+
// gestures are disabled the header is rendered as ordinary sheet content instead, and
87+
// tapping the empty space next to the menu actions can no longer close the sheet by
88+
// accident. The only ways out are then the menu actions and (on wide screens) the scrim.
89+
dragHandle = if (gesturesEnabled) header else null,
8590
sheetGesturesEnabled = gesturesEnabled
8691
) {
92+
if (!gesturesEnabled)
93+
header()
94+
8795
Column(
8896
verticalArrangement = Arrangement.spacedBy(16.dp),
8997
horizontalAlignment = Alignment.CenterHorizontally,

0 commit comments

Comments
 (0)