Skip to content

Build your personal knowledge base with Trilium Notes

chore(right_pane): basic expand support

Elian Doran5dacfd3ac68a
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
index ef0af28f08..8d41929ccd 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
@@ -51,6 +51,8 @@ export default function RightPanelContainer() {
return () => splitInstance.destroy();
}, [ items ]);
+ const sizesBeforeCollapse = useRef(new WeakMap<HTMLElement, number>());
+
return (
<div id="right-pane">
<RightPanelContext.Provider value={{
@@ -65,12 +67,21 @@ export default function RightPanelContainer() {
const sizes = splitInstance.getSizes();
if (!expanded) {
const sizeBeforeCollapse = sizes[pos];
+ sizesBeforeCollapse.current.set(cardEl, sizeBeforeCollapse);
sizes[pos] = 0;
const itemToExpand = pos > 0 ? pos - 1 : pos + 1;
if (sizes[itemToExpand] > COLLAPSED_SIZE) {
sizes[itemToExpand] += sizeBeforeCollapse;
}
+ } else {
+ const itemToExpand = pos > 0 ? pos - 1 : pos + 1;
+ const sizeBeforeCollapse = sizesBeforeCollapse.current.get(cardEl) ?? 50;
+
+ if (sizes[itemToExpand] > COLLAPSED_SIZE) {
+ sizes[itemToExpand] -= sizeBeforeCollapse;
+ }
+ sizes[pos] = sizeBeforeCollapse;
}
console.log("Set sizes to ", sizes);
splitInstance.setSizes(sizes);