From bd4ebd38938800a9b49e6f2d5d87c9dc40c7c130 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sat, 10 May 2025 09:19:41 +0800 Subject: [PATCH] To avoid the left pane from sometimes being resized to a very small width. --- apps/client/src/services/resizer.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/client/src/services/resizer.ts b/apps/client/src/services/resizer.ts index 2c6c5fdd5..1cce0f993 100644 --- a/apps/client/src/services/resizer.ts +++ b/apps/client/src/services/resizer.ts @@ -26,10 +26,16 @@ function setupLeftPaneResizer(leftPaneVisible: boolean) { } if (leftPaneVisible) { - leftInstance = Split(["#left-pane", "#rest-pane"], { - sizes: [leftPaneWidth, 100 - leftPaneWidth], - gutterSize: DEFAULT_GUTTER_SIZE, - onDragEnd: (sizes) => options.save("leftPaneWidth", Math.round(sizes[0])) + // Delayed initialization ensures that all DOM elements are fully rendered and part of the layout, + // preventing Split.js from retrieving incorrect dimensions due to #left-pane not being rendered yet, + // which would cause the minSize setting to have no effect. + requestAnimationFrame(() => { + leftInstance = Split(["#left-pane", "#rest-pane"], { + sizes: [leftPaneWidth, 100 - leftPaneWidth], + gutterSize: DEFAULT_GUTTER_SIZE, + minSize: [150, 300], + onDragEnd: (sizes) => options.save("leftPaneWidth", Math.round(sizes[0])) + }); }); } }