From a76ca768131ad78eff0dd7edd190ac58edf1ba6c Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Fri, 9 May 2025 22:31:16 +0800 Subject: [PATCH] Only expand/collapse the left pane of the focused window. --- .../src/widgets/buttons/left_pane_toggle.ts | 15 ++++++++++----- .../src/widgets/containers/left_pane_container.ts | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/client/src/widgets/buttons/left_pane_toggle.ts b/apps/client/src/widgets/buttons/left_pane_toggle.ts index f8869ad13..88528add5 100644 --- a/apps/client/src/widgets/buttons/left_pane_toggle.ts +++ b/apps/client/src/widgets/buttons/left_pane_toggle.ts @@ -5,10 +5,13 @@ import { t } from "../../services/i18n.js"; import type { EventData } from "../../components/app_context.js"; export default class LeftPaneToggleWidget extends CommandButtonWidget { + private currentLeftPaneVisible: boolean; constructor(isHorizontalLayout: boolean) { super(); + this.currentLeftPaneVisible = options.is("leftPaneVisible"); + this.class(isHorizontalLayout ? "toggle-button" : "launcher-button"); this.settings.icon = () => { @@ -21,7 +24,7 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget { this.settings.title = () => (options.is("leftPaneVisible") ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel")); - this.settings.command = () => (options.is("leftPaneVisible") ? "hideLeftPane" : "showLeftPane"); + this.settings.command = () => (this.currentLeftPaneVisible ? "hideLeftPane" : "showLeftPane"); if (isHorizontalLayout) { this.settings.titlePlacement = "bottom"; @@ -29,13 +32,15 @@ export default class LeftPaneToggleWidget extends CommandButtonWidget { } refreshIcon() { - super.refreshIcon(); - - splitService.setupLeftPaneResizer(options.is("leftPaneVisible")); + if (document.hasFocus() || this.currentLeftPaneVisible === true) { + super.refreshIcon(); + splitService.setupLeftPaneResizer(this.currentLeftPaneVisible); + } } entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { - if (loadResults.isOptionReloaded("leftPaneVisible")) { + if (loadResults.isOptionReloaded("leftPaneVisible") && document.hasFocus()) { + this.currentLeftPaneVisible = options.is("leftPaneVisible"); this.refreshIcon(); } } diff --git a/apps/client/src/widgets/containers/left_pane_container.ts b/apps/client/src/widgets/containers/left_pane_container.ts index 21d4b280e..2b8221553 100644 --- a/apps/client/src/widgets/containers/left_pane_container.ts +++ b/apps/client/src/widgets/containers/left_pane_container.ts @@ -17,7 +17,7 @@ export default class LeftPaneContainer extends FlexContainer { } entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { - if (loadResults.isOptionReloaded("leftPaneVisible")) { + if (loadResults.isOptionReloaded("leftPaneVisible") && document.hasFocus()) { const visible = this.isEnabled(); this.toggleInt(visible);