Describe the bug
ModalNavigationDrawer does not close if clicked in the scrim area while not moving the mouse - also see the steps to reproduce inside the code snippet
Affected platforms
Desktop (Windows, Linux, macOS)
Versions
Kotlin version*: 1.9.23
Compose Multiplatform version*: 1.6.10-dev1551
OS version(s)* (required for Desktop and iOS issues): win11
OS architecture (x86 or arm64): x64
JDK (for desktop issues): 20.0.2
gradle : 8.7
To Reproduce
see code snippet
Expected behavior
close drawer on scrim area
Screenshots
can provide video but it is easy reproducible
Additional context
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.DrawerState
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.ModalDrawerSheet
import androidx.compose.material3.ModalNavigationDrawer
import androidx.compose.material3.Text
import androidx.compose.material3.rememberDrawerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
@Composable
fun ModalNavigationDrawerMouseClickBug() {
val coroutineScopeState: CoroutineScope = rememberCoroutineScope()
val drawerState: DrawerState = rememberDrawerState(DrawerValue.Closed)
ModalNavigationDrawer(
drawerState = drawerState,
content = {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Button(onClick = {
coroutineScopeState.launch {
drawerState.open()
}
}) {
Text(
text = "1. click on this button to open the drawer (somewhere on the right to not be in the sheet area) - " +
"2. dont move the mouse - " +
"3. click again (you can click multiple times) - " +
"4. you see the button gets clicked (sometimes) but nothing happens - " +
"5. it should close the drawer, which it does if you move the mouse and" +
" click somewhere in the scrimed area"
)
}
}
},
drawerContent = {
ModalDrawerSheet {
}
}
)
}
Describe the bug ModalNavigationDrawer does not close if clicked in the scrim area while not moving the mouse - also see the steps to reproduce inside the code snippet
Affected platforms
Versions
To Reproduce see code snippet
Expected behavior close drawer on scrim area
Screenshots can provide video but it is easy reproducible
Additional context