google/accompanist

[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

  1. Scenario
    Add a bottom sheet using bottomSheet(route = "sheet") {
    Dismiss the bottom sheet by clicking outside of the bottom sheet
    The DisposableEffect(Unit) is not called
    Go to an another screen -> the DisposableEffect(Unit) is called

  2. Scenario
    Add a bottom sheet using bottomSheet(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

  1. The DisposableEffect(Unit) is called when the bottom sheet is not visible
  2. 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.