You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BackHandlers declared inside a bottomSheet 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 the BackHandler: it pops the back stack instead.
Checkout the bug/bottom-sheet-back-handler branch in my fork
Run the sample app
Open the "Navigation: Bottom Sheets" sample
Click "Show sheet!"
Press back: the toast appears with "Back pressed!"
Background, then foreground the app
Press back again
EXPECTED: 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:
The callback from NavHostController (upon clicking "Navigation: Bottom Sheets")
The one from BottomSheetNavigator (upon clicking "Show sheet!")
My callback from BottomSheetNavSample (right after)
But when I background and foreground the app, this same method gets called with a different (wrong) order:
The callback from NavHostController
My callback from BottomSheetNavSample
The one from BottomSheetNavigator
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?
The text was updated successfully, but these errors were encountered:
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: 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?
The text was updated successfully, but these errors were encountered: