Below dialog does not dismiss when clicked outside...
# compose
r
Below dialog does not dismiss when clicked outside. Am I missing something or is this expected? Only
usePlatformDefaultWidth=true
dismisses it when clicked outside.
Copy code
Dialog(onDismissRequest = {...
    }, properties = DialogProperties(
        usePlatformDefaultWidth = false,
    ), content = {
        Surface(modifier = Modifier.fillMaxSize().padding(56.dp)
        ) {
s
Not super familiar with Compose dialogs, but I think that's because usePlatformDefaultWidth causes the content to span the whole screen?
👍 1
w
If you're filling max size, there is no outside to click on.
1
👍 1
r
Thanks both, I guess it's that, I thought giving the surface padding would suffice but I'll have to manually check for clicks "inside"
s
Yeah, and in particular material's
Surface
actually blocks touch passthrough
Unsure about this, but it should work if you use a regular
Box
to apply the padding, the the surface inside it.
w
I think you'd still have to handle the click manually on the Box, but maybe not and the dialog catches unhandled clicks.
👍 1
Alternatively if your goal is an inset dialog, technically you could do
.width(windowWidth - padding)
and the click outside should just work.
r
Yep that worked, thanks!