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

LibWeb: Scroll to "nearest" instead of "start" in set_focused_element()

Fixes a bug when after clicking on a button/click the page is scrolled
to start of the element.
This commit is contained in:
Aliaksandr Kalenik 2023-12-18 21:31:31 +01:00 committed by Andreas Kling
parent cda1d886df
commit f6f80a1a72

View file

@ -1700,8 +1700,12 @@ void Document::set_focused_element(Element* element)
m_layout_root->set_needs_display();
// Scroll the viewport if necessary to make the newly focused element visible.
if (m_focused_element)
(void)m_focused_element->scroll_into_view();
if (m_focused_element) {
ScrollIntoViewOptions scroll_options;
scroll_options.block = Bindings::ScrollLogicalPosition::Nearest;
scroll_options.inline_ = Bindings::ScrollLogicalPosition::Nearest;
(void)m_focused_element->scroll_into_view(scroll_options);
}
}
void Document::set_active_element(Element* element)