From 854319441c672bf8a2db9ca9517179619fe9dc8d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 16 Nov 2024 19:36:12 +1000 Subject: [PATCH] ImGuiFullscreen: Fix position resetting to top of list on popup close --- src/util/imgui_fullscreen.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/util/imgui_fullscreen.cpp b/src/util/imgui_fullscreen.cpp index a8784b428..1791828d4 100644 --- a/src/util/imgui_fullscreen.cpp +++ b/src/util/imgui_fullscreen.cpp @@ -639,8 +639,6 @@ bool ImGuiFullscreen::ResetFocusHere() if (ImGui::FindBlockingModal(window)) return false; - s_focus_reset_queued = FocusResetType::None; - // Set the flag that we drew an active/hovered item active for a frame, because otherwise there's one frame where // there'll be no frame drawn, which will cancel the animation. Also set the appearing flag, so that the default // focus set does actually go through. @@ -651,7 +649,12 @@ bool ImGuiFullscreen::ResetFocusHere() } ImGui::SetWindowFocus(); - ImGui::NavInitWindow(window, true); + + // If this is a popup closing, we don't want to reset the current nav item, since we were presumably opened by one. + if (s_focus_reset_queued != FocusResetType::PopupClosed) + ImGui::NavInitWindow(window, true); + + s_focus_reset_queued = FocusResetType::None; // only do the active selection magic when we're using keyboard/gamepad return (GImGui->NavInputSource == ImGuiInputSource_Keyboard || GImGui->NavInputSource == ImGuiInputSource_Gamepad);