1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 01:42:59 +08:00

update selected section on children count change

This commit is contained in:
Davran Dilshat 2021-08-23 16:27:29 +01:00
parent 34b51100ff
commit 9a507ed273

View File

@ -202,6 +202,8 @@ namespace osu.Game.Graphics.Containers
});
}
private int lastKnownChildrenCount = 0;
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
@ -220,10 +222,12 @@ namespace osu.Game.Graphics.Containers
}
float currentScroll = scrollContainer.Current;
var presentChildren = Children.Where(c => c.IsPresent);
if (currentScroll != lastKnownScroll)
if (currentScroll != lastKnownScroll || presentChildren.Count() != lastKnownChildrenCount)
{
lastKnownScroll = currentScroll;
lastKnownChildrenCount = presentChildren.Count();
// reset last clicked section because user started scrolling themselves
if (scrollContainer.UserScrolling)
@ -249,8 +253,6 @@ namespace osu.Game.Graphics.Containers
float scrollCentre = fixedHeaderSize + scrollContainer.DisplayableContent * scroll_y_centre + selectionLenienceAboveSection;
var presentChildren = Children.Where(c => c.IsPresent);
if (lastClickedSection != null)
SelectedSection.Value = lastClickedSection;
else if (Precision.AlmostBigger(0, scrollContainer.Current))