1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:17:35 +00:00

LibGUI: Clear selected index of Breadcrumbbar if segment is removed

If the segment corresponding to the selected index is removed the index
is no longer valid.
This commit is contained in:
Jannis Weis 2022-08-21 21:45:43 +02:00 committed by Andreas Kling
parent 3911758277
commit 32205495e6

View file

@ -68,6 +68,7 @@ void Breadcrumbbar::clear_segments()
{
m_segments.clear();
remove_all_children();
m_selected_segment = {};
}
void Breadcrumbbar::append_segment(String text, Gfx::Bitmap const* icon, String data, String tooltip)
@ -120,6 +121,8 @@ void Breadcrumbbar::remove_end_segments(size_t start_segment_index)
auto segment = m_segments.take_last();
remove_child(*segment.button);
}
if (m_selected_segment.has_value() && *m_selected_segment >= start_segment_index)
m_selected_segment = {};
}
Optional<size_t> Breadcrumbbar::find_segment_with_data(String const& data)