1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

LibGUI: Scroll selection into view when the IconView is first laid out

If we set selection before the IconView is laid out, it has no size.
So it can't correctly calculate where to scroll. Forcing scroll after
the first resize fixes that.
This commit is contained in:
speles 2021-03-01 23:32:27 +02:00 committed by Andreas Kling
parent 6e16a5cdfa
commit d64d2e4d09
2 changed files with 8 additions and 0 deletions

View file

@ -72,6 +72,12 @@ void IconView::resize_event(ResizeEvent& event)
{
AbstractView::resize_event(event);
update_content_size();
if (!m_had_valid_size) {
m_had_valid_size = true;
if (!selection().is_empty())
scroll_into_view(selection().first());
}
}
void IconView::reinit_item_cache() const