Skip to content

Commit 50ae871

Browse files
committed
fix: enforce minimum 100px editor width when resizing plugin panels
Both setPluginPanelWidth() and the drag-based Resizer now account for sidebar width so the editor area cannot be squeezed below 100px.
1 parent 95848b1 commit 50ae871

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

src/view/WorkspaceManager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ define(function (require, exports, module) {
160160
}
161161
});
162162

163-
$mainToolbar.data("maxsize", window.innerWidth*.75);
163+
var sidebarWidth = $("#sidebar").outerWidth() || 0;
164+
$mainToolbar.data("maxsize", Math.min(window.innerWidth * 0.75, window.innerWidth - sidebarWidth - 100));
164165
}
165166

166167

@@ -442,7 +443,8 @@ define(function (require, exports, module) {
442443
// Respect min/max constraints
443444
var minSize = currentlyShownPanel.minWidth || 0;
444445
var minToolbarWidth = minSize + pluginIconsBarWidth;
445-
var maxToolbarWidth = window.innerWidth * 0.75;
446+
var sidebarWidth = $("#sidebar").outerWidth() || 0;
447+
var maxToolbarWidth = Math.min(window.innerWidth * 0.75, window.innerWidth - sidebarWidth - 100);
446448
newToolbarWidth = Math.max(newToolbarWidth, minToolbarWidth);
447449
newToolbarWidth = Math.min(newToolbarWidth, maxToolbarWidth);
448450

test/spec/MainViewManager-integ-test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,39 @@ define(function (require, exports, module) {
12381238
expect(panelContentWidth).toEqual(targetWidth);
12391239
});
12401240
});
1241+
1242+
it("should preserve at least 100px for the editor area", function () {
1243+
pluginPanel.show();
1244+
1245+
// Request an absurdly large width that would squeeze the editor to near-zero
1246+
WorkspaceManager.setPluginPanelWidth(testWindow.innerWidth);
1247+
1248+
const $mainToolbar = _$("#main-toolbar");
1249+
const sidebarWidth = _$("#sidebar").outerWidth() || 0;
1250+
const toolbarWidth = $mainToolbar.width();
1251+
const editorWidth = testWindow.innerWidth - sidebarWidth - toolbarWidth;
1252+
1253+
// Editor area must retain at least 100px
1254+
expect(editorWidth).toBeGreaterThanOrEqual(100);
1255+
});
1256+
1257+
it("should set drag-based maxsize to preserve at least 100px for the editor", function () {
1258+
pluginPanel.show();
1259+
1260+
// Trigger a layout recompute so updateResizeLimits runs
1261+
WorkspaceManager.recomputeLayout(true);
1262+
1263+
const $mainToolbar = _$("#main-toolbar");
1264+
const sidebarWidth = _$("#sidebar").outerWidth() || 0;
1265+
const maxSize = $mainToolbar.data("maxsize");
1266+
1267+
// maxSize must leave at least 100px for the editor
1268+
const editorWidthAtMax = testWindow.innerWidth - sidebarWidth - maxSize;
1269+
expect(editorWidthAtMax).toBeGreaterThanOrEqual(100);
1270+
1271+
// maxSize should also not exceed 75% of window width
1272+
expect(maxSize).toBeLessThanOrEqual(testWindow.innerWidth * 0.75);
1273+
});
12411274
});
12421275
});
12431276
});

0 commit comments

Comments
 (0)