Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ModalBottomSheet] - Paddings passed to Sheet() blocks dismissal of the sheet when clicked #49

Open
MFlisar opened this issue Dec 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@MFlisar
Copy link

MFlisar commented Dec 10, 2024

Problem

You do already support dismissOnClickOutside in bottom sheets. In your demos you apply styles that add some padding around the content sheet on larger screens. In this case though, it's currently not possible to handle this padding as "background which closes the sheet on click". This means, that I have to write my own scrim composable that handles the touches and closes the sheet if I want to achieve that touching the padding around the content is handled like a touch on the scrim. Not a big thing, but still, as you already support dismissOnClickOutside I think this is an unnecessary restriction.

Suggestion

My suggestion would be to change the API of your scrim and let it wrap its content instead of placing the scrim and the sheet side by side. In this case, the scrim could support content padding and could take care of handling the clicks on the padding as well.

OLD

ModalBottomSheet(
    state = modalSheetState
) {
    Scrim()
    Sheet(
        modifier = if (isCompact) Modifier else Modifier.padding(horizontal = 56.dp)
    ) {
        // Content
    }
}

New

Place the sheet inside the scrim box.

ModalBottomSheet(
    state = modalSheetState
) {
    Scrim(
        modifier = Modifier.let { if (isCompact) it else it.padding(horizontal = 56.dp) }
    ) {
        Sheet(
            modifier = Modifier
        ) {
            // Content
        }
    }
}
@alexstyl
Copy link
Member

To clarify, are you saying that spacing on the sides of the sheet currently doesn't dismiss the sheet when clicked?

@MFlisar
Copy link
Author

MFlisar commented Dec 10, 2024

Yes, but just inside the padding from Modifier.padding(horizontal = 56.dp). Because this padding is overlaying the scrim and therefore is handled as click on the sheet although visually its clicking outside the sheet...

@alexstyl alexstyl changed the title BottomSheet - Scrim suggestion [ModalBottomSheet] - Paddings passed to Sheet() blocks dismissal of the shit when clicked Dec 10, 2024
@alexstyl alexstyl added the bug Something isn't working label Dec 10, 2024
@alexstyl alexstyl changed the title [ModalBottomSheet] - Paddings passed to Sheet() blocks dismissal of the shit when clicked [ModalBottomSheet] - Paddings passed to Sheet() blocks dismissal of the sheet when clicked Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants