Incorrect behaviour when bottom sheet is closed by clicking on its background
michal-chojnacki opened this issue · 4 comments
michal-chojnacki commented
Describe the bug
When the bottom sheet is closed by clicking on the background before it's fully expanded, the next navigation shows two bottom sheets sequentially. In that situation I can see that bottom sheet is not popped from navController
To Reproduce
Run code like below:
setContent {
val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)
TestNavTheme {
ModalBottomSheetLayout(
bottomSheetNavigator = bottomSheetNavigator,
) {
NavHost(navController, "home") {
composable("home") {
Column(
modifier = Modifier.fillMaxSize(),
) {
Text(text = "Hello!")
Button(onClick = {
navController.navigate("sheet")
}) {
Text(text = "Click me!")
}
}
}
bottomSheet(route = "sheet") {
Text(
modifier = Modifier.height(360.dp),
text = "This is a cool bottom sheet!"
)
}
}
}
}
}
Then:
- Click on "Click me` button which triggers the display of bottom sheet
- Before bottom sheet is fully expanded click on the background
- Bottom sheet stays in the
navController#currentBackStackEntry
even though it was closed. - Click on "Click me` button again
- Now bottom sheet is shown but when we will close it, the next instance will be displayed
Expected behavior
Clicking on the background of a not fully expanded bottom sheet will hide it. After that action bottom sheet is popped from navController
backstack. On the next navigation, only one bottom sheet will be displayed.
Screenshots?
Screen_recording_20231122_125517.webm
Environment:
- Android 14.0
- Emulator
- Accompanist v0.32.0