Winson Chiu
03/24/2025, 4:51 AMbindToNavigation
, what's the right way to navigate back in common code? Neither popBackStack
nor navigateUp
replicate browser back for me. Normal navigation does something like:
A -> B -> C -> browser back -> B -> browser back -> A
Whereas the nav methods go:
A -> B -> C -> popBackState/navigateUp -> B -> browser back -> C -> browser back -> BKonstantin Tskhovrebov
03/24/2025, 10:14 AMKonstantin Tskhovrebov
03/24/2025, 10:26 AMKonstantin Tskhovrebov
03/24/2025, 10:27 AMWinson Chiu
03/24/2025, 1:43 PMKonstantin Tskhovrebov
03/24/2025, 4:40 PMandroidx.navigation
class integrate with the browser History API to provide a consistent experience when using the browser's back and forward buttons. Whenever you navigate using the navController
, a History API entry is added to the browser's history stack. Pressing the back button uses reverse chronological navigation, meaning that the user is taken to the previously visited location that was shown using the navController
. This means that if the user pops a page from the back stack
and then presses the browser back button the previous page is pushed back onto the stack.Winson Chiu
03/24/2025, 5:10 PMNavHostController
to delegate it to window.history.popState(
)?
When I'm using an app, which one I hit is basically determined on a whim, and the fact the 2 don't have the same behavior is weird.Konstantin Tskhovrebov
03/24/2025, 7:17 PMwhat the system back doesthere is no a such thing as "system back"
Konstantin Tskhovrebov
03/24/2025, 7:17 PMWinson Chiu
03/24/2025, 7:20 PMKonstantin Tskhovrebov
03/24/2025, 7:23 PMAltynbek Nurtaza
03/25/2025, 9:59 AMWinson Chiu
03/25/2025, 1:34 PMwindow.history.back()
on wasmJs and popBackStack
on other platforms.