diff --git a/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs b/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs index 8d3e7594ef..f15b235210 100644 --- a/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs +++ b/Content.Client/UserInterface/Systems/CloseWindow/CloseRecentWindowUIController.cs @@ -27,6 +27,7 @@ public sealed partial class CloseRecentWindowUIController : UIController // (Does not need to be unlistened since UIControllers live forever) _uiManager.OnKeyBindDown += OnKeyBindDown; _uiManager.WindowRoot.OnChildAdded += OnRootChildAdded; + _uiManager.WindowRoot.OnChildRemoved += OnRootChildRemoved; _inputManager.SetInputCommand(EngineKeyFunctions.WindowCloseRecent, InputCmdHandler.FromDelegate(session => CloseMostRecentWindow())); @@ -122,6 +123,14 @@ public sealed partial class CloseRecentWindowUIController : UIController } } + private void OnRootChildRemoved(Control control) + { + if (control is BaseWindow window) + { + recentlyInteractedWindows.Remove(window); + } + } + /// /// Checks whether there are any windows that can be closed. ///