From 5121437bcf02c4d67e173bf2fb6cab6a814d0356 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 4 May 2026 11:49:12 -0600 Subject: [PATCH] UI: Avoid looping at end of window content --- src/dusk/ui/settings.cpp | 1 - src/dusk/ui/ui.cpp | 6 ++++-- src/dusk/ui/window.cpp | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dusk/ui/settings.cpp b/src/dusk/ui/settings.cpp index 5a6c1cb941..8224bc4945 100644 --- a/src/dusk/ui/settings.cpp +++ b/src/dusk/ui/settings.cpp @@ -136,7 +136,6 @@ SelectButton& config_percent_select(Pane& leftPane, Pane& rightPane, ConfigVar(content, Pane::Type::Controlled); auto& rightPane = add_child(content, Pane::Type::Uncontrolled); diff --git a/src/dusk/ui/ui.cpp b/src/dusk/ui/ui.cpp index 8d9d827333..426901d8d9 100644 --- a/src/dusk/ui/ui.cpp +++ b/src/dusk/ui/ui.cpp @@ -97,8 +97,10 @@ void update() noexcept { if (auto* context = aurora::rmlui::get_context(); context != nullptr && context->GetFocusElement() == nullptr) { - if (auto* top = top_document()) { - top->focus(); + for (auto& doc : std::views::reverse(sDocuments)) { + if (!doc->closed() && !doc->pending_close() && doc->focus()) { + break; + } } } diff --git a/src/dusk/ui/window.cpp b/src/dusk/ui/window.cpp index 79a0d7e11d..fda098f63b 100644 --- a/src/dusk/ui/window.cpp +++ b/src/dusk/ui/window.cpp @@ -198,6 +198,9 @@ bool Window::handle_content_nav(Rml::Event& event, NavCommand cmd) noexcept { return true; } return false; + } else if (cmd == NavCommand::Down) { + // End of content, avoid looping + return true; } else if (cmd == NavCommand::Cancel) { int currentComponent = -1; for (int i = 0; i < mContentComponents.size(); ++i) {