Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/right pane: tweak
Adorian Doranf27f34b39ebb
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.css b/apps/client/src/widgets/sidebar/RightPanelContainer.cssindex 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-overbackground: 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.tsxindex 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 }: { widgetsByParedrag tracking isn't interrupted. Always rendered + CSS-toggled to keep the host'schild 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 }: { widgetsByPareicon="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 ]);}