Change ListContainer to send null when selected is removed from the data (#20595)

This commit is contained in:
ShadowCommander
2023-10-24 19:07:47 -07:00
committed by GitHub
parent 3007200832
commit 4b10cab617
3 changed files with 12 additions and 6 deletions

View File

@@ -22,7 +22,7 @@ public sealed class ListContainer : Control
}
public bool Toggle { get; set; }
public Action<ListData, ListContainerButton>? GenerateItem;
public Action<BaseButton.ButtonEventArgs, ListData>? ItemPressed;
public Action<BaseButton.ButtonEventArgs?, ListData?>? ItemPressed;
public IReadOnlyList<ListData> Data => _data;
private const int DefaultSeparation = 3;
@@ -92,6 +92,12 @@ public sealed class ListContainer : Control
_data = data.ToList();
_updateChildren = true;
InvalidateArrange();
if (_selected != null && !data.Contains(_selected))
{
_selected = null;
ItemPressed?.Invoke(null, null);
}
}
public void DirtyList()