[Navigation Material] DisposableEffect onDispose is not called at the right time for bottom sheet
kataRebuy opened this issue · 1 comments
Description
I am using the custom bottom sheet navigation through the nav graph. I wanted to know when the bottom sheet is dismissed so I tried to use a DisposableEffect
but the effect itself is not called when the bottom sheet is closed. It is only called when I navigate to another screen.
Also because of this if I add a BackHandler
into the bottom sheet and I dismiss the bottom sheet by clicking outside then when triggering the backHandler the bottom sheet's back handler will be called which is not expected.
Steps to reproduce
-
Scenario
Add a bottom sheet usingbottomSheet(route = "sheet") {
Dismiss the bottom sheet by clicking outside of the bottom sheet
TheDisposableEffect(Unit)
is not called
Go to an another screen -> theDisposableEffect(Unit)
is called -
Scenario
Add a bottom sheet usingbottomSheet(route = "sheet") {
Dismiss the bottom sheet by clicking outside of the bottom sheet
Trigger the back handler
The back handler of the bottom sheet is triggered
Expected behavior
- The
DisposableEffect(Unit)
is called when the bottom sheet is not visible - The BackHandler of the bottom sheet should not be called when it is not visible
Additional context
Using version 0.34.0
With the release of Compose Material 1.7.0-alpha04, the Material team has added a new artifact: androidx.compose.material:material-navigation
, which fully replaces Accompanist Navigation Material.
As such, we are closing all issues here on Accompanist and will be fully deprecating Accompanist Navigation Material in an upcoming release.
A number of issues were fixed as part of the migration, but if you're still seeing an issue, please file an issue with a sample project that reproduces your issue and the Material team will take a look.