Skip to content

Commit

Permalink
Handle non-alive menu items during addition/removal
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Nov 24, 2023
1 parent f4f4e31 commit 6e483d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions osu.Framework/Graphics/UserInterface/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void Insert(int position, MenuItem item)

drawableItem.SetFlowDirection(Direction);

var items = ItemsContainer.FlowingChildren.Cast<DrawableMenuItem>().ToList();
var items = Children.OrderBy(ItemsContainer.GetLayoutPosition).ToList();

for (int i = position; i < items.Count; i++)
ItemsContainer.SetLayoutPosition(items[i], i + 1);
Expand All @@ -318,7 +318,7 @@ private void itemStateChanged(DrawableMenuItem item, MenuItemState state)
/// <returns>Whether <paramref name="item"/> was successfully removed.</returns>
public bool Remove(MenuItem item)
{
var items = ItemsContainer.FlowingChildren.Cast<DrawableMenuItem>().ToList();
var items = Children.OrderBy(ItemsContainer.GetLayoutPosition).ToList();
bool removed = false;

for (int i = 0; i < items.Count; i++)
Expand Down

0 comments on commit 6e483d7

Please sign in to comment.