From b29ff7b64269e7638ed696fd7bfa56b59a46c037 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Wed, 14 Oct 2026 18:55:22 +0200 Subject: [PATCH] Fix the editor selection tab staying open after the selection is cleared --- .../Widgets/Logic/Editor/MapEditorTabsLogic.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs index 6f1464f..a2254a3 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/MapEditorTabsLogic.cs @@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic editor = widget.Parent.Parent.Get("MAP_EDITOR"); editor.DefaultBrush.UpdateSelectedTab += HandleUpdateSelectedTab; + editor.DefaultBrush.SelectionChanged += HandleSelectionChanged; SetupTab("SELECT_TAB", "SELECT_WIDGETS", MenuType.Select); SetupTab("TILES_TAB", "TILE_WIDGETS", MenuType.Tiles); @@ -51,6 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic protected override void Dispose(bool disposing) { editor.DefaultBrush.UpdateSelectedTab -= HandleUpdateSelectedTab; + editor.DefaultBrush.SelectionChanged -= HandleSelectionChanged; base.Dispose(disposing); } @@ -96,5 +98,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic OnTabChanged?.Invoke(); } + + void HandleSelectionChanged() + { + // Editor actions (e.g. deleting the selected actor or undo/redo) can clear the selection + // without going through UpdateSelectedTab, so make sure we don't stay on the disabled tab. + if (menuType == MenuType.Select && !editor.DefaultBrush.Selection.HasSelection) + { + menuType = lastSelectedTab; + OnTabChanged?.Invoke(); + } + } } }