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 toggle handle: keep the handle in fixed position
Adorian Doran32528afc3863
diff --git a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.css b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.cssindex 39e6f95604..ba435562ef 100644--- a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.css+++ b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.css@@ -1,8 +1,15 @@-/* The handle is a flex sibling of #right-pane inside #vertical-main-container,- so it reserves its own 12px column and fully owns its background. */+/* The handle is absolutely positioned in a reserved gutter on the right edge of+ #vertical-main-container, so it stays fixed at the viewport's right side and fully+ owns its background — independent of whether the panel is open or collapsed. */.right-pane-toggle-handle {- /* Inherited from #right-pane-wrapper (RightPanelContainer.css); fallback for safety. */- flex: 0 0 var(--right-pane-handle-width, 12px);+ /* Pinned to the reserved gutter (see #vertical-main-container in RightPanelContainer.css);+ width inherits --right-pane-handle-width, with a fallback for safety. */+ position: absolute;+ inset-inline-end: 0;+ top: 0;+ bottom: 0;+ width: var(--right-pane-handle-width, 12px);+ z-index: 1;display: flex;align-items: center;justify-content: center;@@ -13,7 +20,6 @@padding: 0;font-size: 16px;cursor: pointer;- margin-right: 2px;&.right-pane-toggle-handle-action-expand {background: var(--note-split-background-color, var(--main-background-color));@@ -28,4 +34,4 @@&:hover {background-color: var(--hover-item-background-color);}-}\ No newline at end of file+}diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.css b/apps/client/src/widgets/sidebar/RightPanelContainer.cssindex fa5b506c4c..f943ee216c 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.css+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.css@@ -1,19 +1,14 @@-/* Split target: lays out the toggle handle (fixed) next to the panel (filling).- When the pane is collapsed, Split sets no width, so the wrapper must not shrink past- the handle. `flex-shrink: 0` + a `min-width` of the handle width keep the handle strip- visible against #center-pane's growth. The handle (RightPaneToggleHandle.css) inherits- `--right-pane-handle-width`; keep `minSize` in RightPanelContainer.tsx in sync too. */-body.experimental-feature-new-layout #right-pane-wrapper {+/* Reserve a fixed-width gutter on the viewport's right edge for the toggle handle, which is+ absolutely positioned within it (see RightPaneToggleHandle.css). Split sizes the panes+ inside the padded content box, so they never sit under the handle, and the handle stays put+ regardless of whether the panel is open. */+body.experimental-feature-new-layout #vertical-main-container {--right-pane-handle-width: 12px;- display: flex;- flex-direction: row;- flex-shrink: 0;- min-width: var(--right-pane-handle-width);+ position: relative;+ padding-inline-end: var(--right-pane-handle-width);}body.experimental-feature-new-layout #right-pane {- flex: 1;- min-width: 0;display: flex;flex-direction: column;diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsxindex 65c4b87664..db79a2b4cf 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx@@ -26,9 +26,6 @@ import RightPanelWidget from "./RightPanelWidget";import TableOfContents from "./TableOfContents";const MIN_WIDTH_PERCENT = 5;-const RIGHT_PANE_MIN_CONTENT_PX = 180;-// Keep in sync with `--right-pane-handle-width` in RightPanelContainer.css.-const HANDLE_WIDTH_PX = 12;interface RightPanelWidgetDefinition {el: VNode;@@ -49,11 +46,9 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare}, []));return (- <div id="right-pane-wrapper">- {/* The wrapper is the split target, so the resize gutter stays on the outer- boundary (between #center-pane and the wrapper). The handle is a sibling of- #right-pane — it owns its background and isn't clipped by the pane's overflow —- and sits just inside the gutter, against the panel. */}+ <>+ {/* Absolutely positioned in a reserved gutter on the viewport's right edge, so it+ stays put regardless of the panel's open/collapsed state (see RightPanelContainer.css). */}<RightPaneToggleHandle /><div id="right-pane">{rightPaneVisible && (@@ -72,7 +67,7 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare))}</div>- </div>+ </>);}@@ -155,10 +150,10 @@ function useSplit(visible: boolean) {// 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 splitInstance = Split(["#center-pane", "#right-pane-wrapper"], {+ const splitInstance = Split(["#center-pane", "#right-pane"], {sizes: [100 - rightPaneWidth, rightPaneWidth],gutterSize: DEFAULT_GUTTER_SIZE,- minSize: [300, RIGHT_PANE_MIN_CONTENT_PX + HANDLE_WIDTH_PX], // panel content + handle strip.+ minSize: [300, 180],rtl: glob.isRtl,onDragEnd: (sizes) => options.save("rightPaneWidth", Math.round(sizes[1]))});