Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Enforce minimum width when resizing split panes https://github.com/siyuan-note/siyuan/issues/19588

Daniel102dfdee4dfe
diff --git a/app/src/layout/resizePane.test.ts b/app/src/layout/resizePane.test.ts
index 7216b835a6..2bec676dc3 100644
--- a/app/src/layout/resizePane.test.ts
+++ b/app/src/layout/resizePane.test.ts
@@ -1,6 +1,6 @@
import {describe, it} from "node:test";
import * as assert from "node:assert/strict";
-import {MIN_VERTICAL_PANE_SIZE, resizePanePercentages, splitPanePercentages} from "./resizePane";
+import {MIN_HORIZONTAL_PANE_SIZE, MIN_VERTICAL_PANE_SIZE, resizePanePercentages, splitPanePercentages} from "./resizePane";
describe("layout pane resizing", () => {
it("keeps two panes proportional after resizing", () => {
@@ -31,6 +31,19 @@ describe("layout pane resizing", () => {
assert.deepEqual(resizePanePercentages([100, 400], 0, 1, 100, MIN_VERTICAL_PANE_SIZE), [40, 60]);
});
+ it("keeps horizontal panes usable without resizing other panes", () => {
+ const left = resizePanePercentages([400, 400, 200], 0, 1, -1000, MIN_HORIZONTAL_PANE_SIZE);
+ const right = resizePanePercentages([400, 400, 200], 0, 1, 1000, MIN_HORIZONTAL_PANE_SIZE);
+ [24, 56, 20].forEach((expected, index) => assert.ok(Math.abs(left[index] - expected) < 1e-10));
+ [56, 24, 20].forEach((expected, index) => assert.ok(Math.abs(right[index] - expected) < 1e-10));
+ });
+
+ it("allows a narrow horizontal pane to widen without forcing the layout to jump", () => {
+ assert.deepEqual(resizePanePercentages([100, 400], 0, 1, -50, MIN_HORIZONTAL_PANE_SIZE), [20, 80]);
+ assert.deepEqual(resizePanePercentages([100, 400], 0, 1, 100, MIN_HORIZONTAL_PANE_SIZE), [40, 60]);
+ assert.deepEqual(resizePanePercentages([100, 100], 0, 1, 50, MIN_HORIZONTAL_PANE_SIZE), [50, 50]);
+ });
+
it("normalizes pane sizes before splitting an existing pane", () => {
const percentages = splitPanePercentages([200, 300], 0, true);
diff --git a/app/src/layout/resizePane.ts b/app/src/layout/resizePane.ts
index 6de310dc3c..d69c5a5bcf 100644
--- a/app/src/layout/resizePane.ts
+++ b/app/src/layout/resizePane.ts
@@ -1,4 +1,5 @@
export const MIN_VERTICAL_PANE_SIZE = 200;
+export const MIN_HORIZONTAL_PANE_SIZE = 240;
export const resizePanePercentages = (
sizes: number[],
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 1fee48ac8d..8ece05aeca 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -42,7 +42,7 @@ import {adjustDockPadding} from "./dock/util";
import {setTitle} from "../util/processTitle";
import {activateQueuedAVLocate, queueAVLocateRequest} from "../protyle/render/av/locate";
import {applyDockEntryVisibility} from "../config/entryVisibility/runtime";
-import {MIN_VERTICAL_PANE_SIZE, panePercentages, resizePanePercentages} from "./resizePane";
+import {MIN_HORIZONTAL_PANE_SIZE, MIN_VERTICAL_PANE_SIZE, panePercentages, resizePanePercentages} from "./resizePane";
import {requestResponsiveDockLayout} from "./dock/responsive";
import {stickyRow} from "../protyle/render/av/row";
@@ -1119,7 +1119,7 @@ export const addResize = (obj: Layout | Wnd, after = true) => {
previousIndex,
nextIndex,
delta,
- direction === "tb" ? MIN_VERTICAL_PANE_SIZE : 8,
+ direction === "tb" ? MIN_VERTICAL_PANE_SIZE : MIN_HORIZONTAL_PANE_SIZE,
);
if (percentages) {
setPanePercentages(paneElements, percentages);