Skip to content

Commit be19d1f

Browse files
committed
fix(split pane): hide the close button when no split panes exist
1 parent a22687e commit be19d1f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

apps/client/src/widgets/buttons/close_pane_button.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import { useEffect, useState } from "preact/hooks";
22
import { t } from "../../services/i18n";
33
import ActionButton from "../react/ActionButton";
4-
import { useNoteContext, useTriliumEvent } from "../react/hooks";
4+
import { useNoteContext, useTriliumEvents } from "../react/hooks";
5+
import appContext from "../../components/app_context";
56

67
export default function ClosePaneButton() {
78
const { noteContext, ntxId, parentComponent } = useNoteContext();
8-
const [ isEnabled, setIsEnabled ] = useState(false);
9+
const [isEnabled, setIsEnabled] = useState(false);
910

1011
function refresh() {
11-
setIsEnabled(!!noteContext);
12+
const isMainOfSomeContext = appContext.tabManager.noteContexts.some(c => c.mainNtxId === ntxId);
13+
setIsEnabled(!!(noteContext && (!!noteContext.mainNtxId || isMainOfSomeContext)));
1214
}
1315

14-
useTriliumEvent("noteContextReorder", refresh);
15-
useEffect(refresh, [ ntxId ]);
16+
useTriliumEvents(["noteContextRemoved", "noteContextReorder", "newNoteContextCreated"], refresh);
17+
useEffect(refresh, [ntxId]);
1618

1719
return (
1820
<ActionButton

0 commit comments

Comments
 (0)