# compose-android


10/26/2023, 4:17 PM
I have a single TopAppBar that all the backButton does currently is navController.popBackStack(). I have a screen in my app where I need to check if there are dirty changes, and if there are instead of going back I show a dialog prompting for confirmation about losing the data that's entered. I have a backHandler in my Screen where this Dialog lives, and when I use the system back button it works fine, but obviously using the single TopAppBar which lives in my main app composable is just calling navController.popBackStack() so it's not caring about the backHandler. Is there a way to instead of having the button popBackStack() to have it just replicate the behavior of the system back button, or would it be best to just have a function passed all the way through NavHost/Nested navigation graphs all the way to where I'm needing the different back behavior, or is this enough of a reason to look into using an AppBar per screen instead of a Global one. I know some people use global app bars and some use app bars per screen, and it seems like they both have their tradeoffs.
Video showing me using system back button first, showing the dialog, and then pressing the cancel button in the global TopAppBar which does not care about the backHandler since it just does "navController.popBackStack()"

Stylianos Gakis

10/26/2023, 5:10 PM
Global TopAppBar sounds like hell. I know this doesn't help you right now, but each screen doing its own TopAppBar has been a great decision on our end.


10/26/2023, 5:35 PM
Yeah, I agree. I'm not sure why we made the decision, but it was a decision made early on and it's awful now that we have these screens that we don't want to simply "popBackStack"