From a71191515ac29725ee2aa94b6f5d59cc9ffa108c Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 29 Jan 2025 19:07:28 +0100 Subject: [PATCH] EndMainMenuBar doesn't attempt to restore focus when there's an active id. (#8355) I don't have a specific issue in mind but it seems sane to add that test. --- imgui_widgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e37a2fb45..f772f309c 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -8769,7 +8769,7 @@ void ImGui::EndMainMenuBar() // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window // FIXME: With this strategy we won't be able to restore a NULL focus. ImGuiContext& g = *GImGui; - if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest) + if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest && g.ActiveId == 0) FocusTopMostWindowUnderOne(g.NavWindow, NULL, NULL, ImGuiFocusRequestFlags_UnlessBelowModal | ImGuiFocusRequestFlags_RestoreFocusedChild); End();