From be19d1f5b54a4aa339ecaa5672bd703b347c46ac Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Mon, 17 Nov 2025 09:24:18 +0800 Subject: [PATCH] fix(split pane): hide the close button when no split panes exist --- .../client/src/widgets/buttons/close_pane_button.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/client/src/widgets/buttons/close_pane_button.tsx b/apps/client/src/widgets/buttons/close_pane_button.tsx index 726c5c49e..7ffae309d 100644 --- a/apps/client/src/widgets/buttons/close_pane_button.tsx +++ b/apps/client/src/widgets/buttons/close_pane_button.tsx @@ -1,18 +1,20 @@ import { useEffect, useState } from "preact/hooks"; import { t } from "../../services/i18n"; import ActionButton from "../react/ActionButton"; -import { useNoteContext, useTriliumEvent } from "../react/hooks"; +import { useNoteContext, useTriliumEvents } from "../react/hooks"; +import appContext from "../../components/app_context"; export default function ClosePaneButton() { const { noteContext, ntxId, parentComponent } = useNoteContext(); - const [ isEnabled, setIsEnabled ] = useState(false); + const [isEnabled, setIsEnabled] = useState(false); function refresh() { - setIsEnabled(!!noteContext); + const isMainOfSomeContext = appContext.tabManager.noteContexts.some(c => c.mainNtxId === ntxId); + setIsEnabled(!!(noteContext && (!!noteContext.mainNtxId || isMainOfSomeContext))); } - useTriliumEvent("noteContextReorder", refresh); - useEffect(refresh, [ ntxId ]); + useTriliumEvents(["noteContextRemoved", "noteContextReorder", "newNoteContextCreated"], refresh); + useEffect(refresh, [ntxId]); return (