Preserve focused element on pop

This commit is contained in:
Luke Street
2026-04-30 22:31:24 -06:00
parent 32b4c0567a
commit 39298f8d8f
+7 -2
View File
@@ -35,8 +35,13 @@ Document::~Document() {
void Document::show() {
if (mDocument != nullptr) {
mDocument->Show();
focus();
// Attempt to preserve the previously focused element
mDocument->Show(Rml::ModalFlag::None, Rml::FocusFlag::Keep);
// If nothing is focused, let the document decide the initial focus
auto* leaf = mDocument->GetFocusLeafNode();
if (leaf == nullptr || leaf == mDocument) {
focus();
}
}
}