Is there a way to navigate back inside a bottom sh...
# compose
s
Is there a way to navigate back inside a bottom sheet? I have 2 composables inside a bottom sheet. When I navigate to the second screen, the back button dismisses the bottom sheet instead of navigating back to the first screen. Navigation works well as long as the back button is not involved. Yet
BackHandler
inside the composables don’t get called 🤔
i
Is this a bottom sheet created via Accompanist Navigation Material? https://google.github.io/accompanist/navigation-material/
s
No, it's a fragment bottom sheet that add a navhost and these two destinations in its content
i
So it is a
BottomSheetDialogFragment
that creates a compose
NavHost
inside of it?
If so, make sure you are using AppCompat 1.5.0-alpha01 or higher, since that's the only one that hooks up the
OnBackPressedDispatcher
to the dialog correctly: https://developer.android.com/jetpack/androidx/releases/appcompat?hl=en#1.5.0-alpha01
s
Thanks a lot! I'll check my dependencies 🙏
Hmm I did update my dependencies: • appCompat 1.4.1 => 1.5.1 • material 1.6.1 => 1.7.0
BottomSheetDialogFragment
comes from material so it targets appCompat 1.5.0. However, my bottom sheet still gets dismissed on back pressed from the second destination 😕
249 Views