1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:37:35 +00:00

LibWeb: Scroll elements into view when they become focused

This makes both user-interactive (tab keys) and programmatic focus
changes scroll the viewport if necessary to reveal the newly focused
element.
This commit is contained in:
Andreas Kling 2022-10-11 12:15:46 +02:00
parent 7dcbb403bb
commit 5ab501c92f
2 changed files with 5 additions and 1 deletions

View file

@ -1427,6 +1427,10 @@ void Document::set_focused_element(Element* element)
if (m_layout_root)
m_layout_root->set_needs_display();
// Scroll the viewport if necessary to make the newly focused element visible.
if (m_focused_element)
m_focused_element->scroll_into_view();
}
void Document::set_active_element(Element* element)