diff --git a/CHANGELOG.md b/CHANGELOG.md index 1423c14..c83c1f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Additions Fixes - Fixed auto-nav tooltip displaying on the selected element even when not in auto-nav mode - Fixed radio buttons not unchecking all other radio buttons with the same root element +- Fixed elements not being deselected when removed through RemoveChild ## 5.3.0 ### MLEM diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index 378be87..7b579b8 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -485,6 +485,8 @@ namespace MLEM.Ui.Elements { /// The child element to remove public virtual void RemoveChild(Element element) { this.children.Remove(element); + if (this.Root?.SelectedElement == element) + this.Root.SelectElement(null); // set area dirty here so that a dirty call is made // upwards to us if the element is auto-positioned element.SetAreaDirty();