diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f86062..b737ea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Improvements - Automatically update all elements when changing a ui system's viewport - Allow setting a default color for clickable links in UiStyle - Allow ElementHelper's KeybindButton to query a combination at a given index +- Automatically select the first element when a dropdown is opened in auto nav mode Fixes - Fixed paragraph links having incorrect hover locations when using special text alignments diff --git a/MLEM.Ui/Elements/Dropdown.cs b/MLEM.Ui/Elements/Dropdown.cs index 185c1c5..c49c2c6 100644 --- a/MLEM.Ui/Elements/Dropdown.cs +++ b/MLEM.Ui/Elements/Dropdown.cs @@ -22,6 +22,13 @@ namespace MLEM.Ui.Elements { set { this.Panel.IsHidden = !value; this.OnOpenedOrClosed?.Invoke(this); + + // select the first dropdown element in auto nav mode + if (value && this.Controls.IsAutoNavMode) { + var firstChild = this.Panel.GetChildren().FirstOrDefault(c => c.CanBeSelected); + if (firstChild != null) + this.Root.SelectElement(firstChild, true); + } } } ///