UI: Refocus top document automatically

This commit is contained in:
Luke Street
2026-05-04 11:14:40 -06:00
parent efcb19a3d0
commit 7ba22b7714
2 changed files with 12 additions and 3 deletions
-3
View File
@@ -66,9 +66,6 @@ Popup::Popup() : Document(kDocumentSource), mRoot(mDocument->GetElementById("pop
Document::hide(mPendingClose);
}
});
// We start hidden, but want focus for an open nav event
mDocument->Focus();
}
void Popup::show() {
+12
View File
@@ -87,9 +87,21 @@ void update() noexcept {
for (const auto& doc : sDocuments) {
doc->update();
}
// Remove closed documents
const auto [first, last] =
std::ranges::remove_if(sDocuments, [](const auto& doc) { return doc->closed(); });
sDocuments.erase(first, last);
// If no documents have focus, explicitly focus the top one
if (auto* context = aurora::rmlui::get_context();
context != nullptr && context->GetFocusElement() == nullptr)
{
if (auto* top = top_document()) {
top->focus();
}
}
sync_input_block();
}