Skip to content

Build your personal knowledge base with Trilium Notes

fix(split pane): hide the close button when no split panes exist

SiriusXTbe19d1f5b54a
diff --git a/apps/client/src/widgets/buttons/close_pane_button.tsx b/apps/client/src/widgets/buttons/close_pane_button.tsx
index 726c5c49e0..7ffae309da 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 (
<ActionButton