fix: skip back navigation when overlay route is on top

This commit is contained in:
edde746
2026-04-12 10:11:11 +02:00
parent 7c3cee692c
commit d56067e7cc
+5
View File
@@ -82,6 +82,11 @@ KeyEventResult handleBackKeyNavigation<T>(BuildContext context, KeyEvent event,
if (!Navigator.canPop(context)) {
return KeyEventResult.ignored;
}
// Don't handle back when a dialog/overlay is on top of our route —
// the overlay handles its own dismissal via DismissAction.
if (ModalRoute.of(context)?.isCurrent != true) {
return KeyEventResult.ignored;
}
// Handle on KeyUpEvent to prevent double-pop when returning from child screens
// (KeyDownEvent can be received by both the popping screen and the returned-to screen)
return handleBackKeyAction(event, () => Navigator.pop(context, result));