Skip to content

Build your personal knowledge base with Trilium Notes

client/right pane: tweak

Adorian Doranf27f34b39ebb
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.css b/apps/client/src/widgets/sidebar/RightPanelContainer.css
index 797d8fec67..a469035638 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.css
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.css
@@ -69,8 +69,8 @@ body.experimental-feature-new-layout #right-pane-host.overlay > .right-pane-over
background: rgba(0, 0, 0, 0.05);
}
-/* Pin/close controls, shown only in overlay mode. */
-body.experimental-feature-new-layout #right-pane .right-pane-overlay-actions {
+/* Pin/close controls, shown whenever the pane is open (pin only in overlay mode). */
+body.experimental-feature-new-layout #right-pane .right-pane-actions {
position: absolute;
top: 4px;
inset-inline-end: 4px;
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
index 317e23599e..c839e9f35a 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
@@ -27,6 +27,7 @@ import RightPanelWidget from "./RightPanelWidget";
import TableOfContents from "./TableOfContents";
const MIN_WIDTH_PERCENT = 5;
+const MAX_WIDTH_PERCENT = 90;
/**
* - `closed`: hidden. - `docked`: a flex pane that reflows the content (resizable via Split).
@@ -83,10 +84,12 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare
drag tracking isn't interrupted. Always rendered + CSS-toggled to keep the host's
child list structurally stable for Split's gutter injection. */}
<div class="right-pane-overlay-spacer" />
- <div id="right-pane">
- {mode === "overlay" && (
- <div class="right-pane-overlay-actions">
- <ActionButton icon="bx bx-pin" text={t("right_pane.dock")} onClick={dock} />
+ {/* Mode class (right-pane-mode-docked / -overlay) as a styling hook; none when closed. */}
+ <div id="right-pane" class={visible ? `right-pane-mode-${mode}` : undefined}>
+ {visible && (
+ <div class="right-pane-actions">
+ {/* Pin only applies while overlaying (it docks the pane); close shows in both modes. */}
+ {mode === "overlay" && <ActionButton icon="bx bx-pin" text={t("right_pane.dock")} onClick={dock} />}
<ActionButton icon="bx bx-x" text={t("right_pane.close")} onClick={close} />
</div>
)}
@@ -98,10 +101,13 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare
icon="bx bx-sidebar"
text={t("right_pane.empty_message")}
>
- <Button
- text={t("right_pane.empty_button")}
- triggerCommand="toggleRightPane"
- />
+ {/* The overlay auto-closes (outside click / focus loss / Esc), so a manual hide button is redundant there. */}
+ {mode !== "overlay" && (
+ <Button
+ text={t("right_pane.empty_button")}
+ triggerCommand="toggleRightPane"
+ />
+ )}
</NoItems>
)
)}
@@ -188,28 +194,39 @@ function useSplit(mode: RightPaneMode) {
if (mode === "closed") return;
// We are intentionally omitting useTriliumOption to avoid re-render due to size change.
- const rightPaneWidth = Math.max(MIN_WIDTH_PERCENT, options.getInt("rightPaneWidth") ?? MIN_WIDTH_PERCENT);
- const saveWidth = (sizes: number[]) => options.save("rightPaneWidth", Math.round(sizes[1]));
+ const rightPaneWidth = Math.min(MAX_WIDTH_PERCENT, Math.max(MIN_WIDTH_PERCENT, options.getInt("rightPaneWidth") ?? MIN_WIDTH_PERCENT));
+
+ // Cap the right pane at MAX_WIDTH_PERCENT. Enforced in onDrag using Split's live percentages
+ // rather than its px-based maxSize, so the cap stays correct across window resizes.
+ let splitInstance: ReturnType<typeof Split> | undefined;
+ const onDrag = (sizes: number[]) => {
+ if (sizes[1] > MAX_WIDTH_PERCENT) {
+ splitInstance?.setSizes([100 - MAX_WIDTH_PERCENT, MAX_WIDTH_PERCENT]);
+ }
+ };
+ const onDragEnd = (sizes: number[]) => options.save("rightPaneWidth", Math.round(sizes[1]));
// Docked: resize the host (and thus the content) against #center-pane.
// Overlay: resize the pane against the spacer inside the absolute host — the content (#center-pane)
// is untouched, so it never reflows.
- const splitInstance = mode === "docked"
+ splitInstance = mode === "docked"
? Split(["#center-pane", "#right-pane-host"], {
sizes: [100 - rightPaneWidth, rightPaneWidth],
gutterSize: DEFAULT_GUTTER_SIZE,
minSize: [300, 180],
rtl: glob.isRtl,
- onDragEnd: saveWidth
+ onDrag,
+ onDragEnd
})
: Split([".right-pane-overlay-spacer", "#right-pane"], {
sizes: [100 - rightPaneWidth, rightPaneWidth],
gutterSize: DEFAULT_GUTTER_SIZE,
minSize: [0, 180],
rtl: glob.isRtl,
- onDragEnd: saveWidth
+ onDrag,
+ onDragEnd
});
- return () => splitInstance.destroy();
+ return () => splitInstance?.destroy();
}, [ mode ]);
}