question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a method to make the bottom sheet non-cancellable for some use-cases.

See original GitHub issue

Describe the bug

Provide a method to make the bottom sheet non-cancellable for some use-cases.

Expected behaviour

When a user clicks the back button or the outside content of the bottom sheet, then it dismisses. However, there should be a way to control that behaviour based on a flag that the bottom sheet should not dismiss. It should only dismiss via calling navGraph.navigateBack().

Environment:

  • Android OS version: [Android 11.0]
  • Device: [Samsung M20]
  • Accompanist version: [0.17.0]

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:10
  • Comments:12

github_iconTop GitHub Comments

2reactions
jossiwolfcommented, Sep 18, 2021

@dilraj-singh1997 Thanks for the feature request. The bottom sheet will always be dismissed when the associated destination is popped of the back stack (such as is the case when going back). I will look into exposing a flag that mirrors ModalBottomSheetLayout's gesturesEnabled flag to disable dismissal by touching outside of the sheet.

@ravitejasc Please don’t do this - BottomSheetNavigator relies on implementation details of ModalBottomSheetState to work. Overriding confirmStateChange does not guarantee this to work and is a good way to get the navigator out of sync. This constructor of BottomSheetNavigator might be made internal in the future.

0reactions
hiteshchopra11commented, Oct 25, 2022

@dimitriz09 As a workaround, I returned false in confirmStateChange of rememberModalBottomSheetState and it worked for me.

    val confirmStateChange: (ModalBottomSheetValue) -> Boolean = remember {
        { false }
    }

    val sheetState = rememberModalBottomSheetState(
        initialValue = ModalBottomSheetValue.Hidden,
        animationSpec = SwipeableDefaults.AnimationSpec,
        confirmStateChange = confirmStateChange
    )
Read more comments on GitHub >

github_iconTop Results From Across the Web

Make your BottomSheetDialog noncancelable - beta - Medium
Here's a workaround to make your bottom sheet dialog noncancelable. Let's find out what makes our bottom sheets canceled first. As mentioned above...
Read more >
Prevent dismissal of BottomSheetDialogFragment on touch ...
According to the BottomSheet specification bottom sheets can be dismissed by touching outside of the bottom sheet, therefore what are my options ...
Read more >
How to Create a Bottom Sheet With Jetpack Compose
Bottom sheets are UI sheets that the user can drag up and down to show or reveal UI components. Very useful! ⭐ Get...
Read more >
Modal Bottom Sheets - Material Design
Using bottom sheets. Before you can use Material bottom sheets, you need to add a dependency to the Material Components for Android library....
Read more >
Basel III: Finalising post-crisis reforms
banks incorporated in jurisdictions that do not allow the use of external ... In case of off-balance sheet claims, the gross amount would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found