From d56067e7cc013c16426f79ad46573f24557144a8 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sun, 12 Apr 2026 10:11:11 +0200 Subject: [PATCH] fix: skip back navigation when overlay route is on top --- lib/focus/key_event_utils.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/focus/key_event_utils.dart b/lib/focus/key_event_utils.dart index 1df5fb6a..0dd64e1e 100644 --- a/lib/focus/key_event_utils.dart +++ b/lib/focus/key_event_utils.dart @@ -82,6 +82,11 @@ KeyEventResult handleBackKeyNavigation(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));