0

I want to disable back button in the new material3 1.1 ModalBottomSheet. But cant get it to work, it always hides on back button in my attempts so far. Any creative ideas?

Code below still hides bottom sheet on back press

@Composable
fun CancellingBottomSheet(subState: Cancelling, onNavigateBackToBasket: () -> Unit) {
    BackHandler {} // disable back while this is showing
    ModalBottomSheet(
        onDismissRequest = {},
        sheetState = rememberModalBottomSheetState(
            skipPartiallyExpanded = true,
            confirmValueChange = { false },
        ),
        dragHandle = {},
    ) {
        BackHandler {} // disable back while this is showing
        Content(subState, onNavigateBackToBasket)
    }
}
Joakim Tall
  • 308
  • 2
  • 7
  • 13
  • 1
    I tried the code exactly as you have it and it works fine, it doesn't hide on back pressed. It's probably version / device specific. I'm using a Google Pixel 6 Pro, Android version 13 – Eliza Camber May 25 '23 at 14:06
  • Thanks for testing. Are you using compose 1.4.3 and material3 1.1.0? I realize I am using compose 1.4.1, might try to upgrade and see if thats it – Joakim Tall May 25 '23 at 17:12
  • Yes, compose 1.4.3 / material3 1.1.0 – Eliza Camber May 29 '23 at 08:22

0 Answers0