Closed david-tixr closed 4 months ago
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.
Description
BackHandler
s declared inside abottomSheet
destination don't always work. The first time they come into the composition, pressing back will correctly trigger them. But after the Activity is stopped (backgrounded) then started again (foregrounded), pressing back doesn't trigger theBackHandler
: it pops the back stack instead.Steps to reproduce
I have forked the repo and added just a few lines to repro in the sample app: https://github.com/google/accompanist/compare/main...david-tixr:bug/bottom-sheet-back-handler
bug/bottom-sheet-back-handler
branch in my forkEXPECTED: the toast should appear ACTUAL: the toast doesn't appear, the sheet is closed instead
Additional context
I've spent some time debugging this issue. A pivotal point is to observe with debug breakpoints how
androidx.activity.OnBackPressedDispatcher$addCancellableCallback
gets called.At first, this is the sequence:
But when I background and foreground the app, this same method gets called with a different (wrong) order:
On a back press, the callback that's been added last is the one that gets called: in this case, the one from BottomSheetNavigator. The question is: why do these callbacks get added back in the wrong order?