Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/utils/Resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,13 @@ define(function (require, exports, module) {
// reposition it if the element size changes externally
function repositionResizer(elementSize) {
var resizerPosition = elementSize || 1;
if (position === POSITION_RIGHT || position === POSITION_BOTTOM) {
$resizer.css(resizerCSSPosition, resizerPosition);
if (position !== POSITION_RIGHT && position !== POSITION_BOTTOM) {
return;
}
if (collapsible && !isVisible($element)) {
return;
}
$resizer.css(resizerCSSPosition, resizerPosition);
}

$element.data("removeSizable", function () {
Expand Down
3 changes: 2 additions & 1 deletion src/view/CentralControlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
}
}

function _restoreExpandedLayout(skipToolbarRestore) {

Check failure on line 157 in src/view/CentralControlBar.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaAwRqz988Jwv2L8HlQm&open=AaAwRqz988Jwv2L8HlQm&pullRequest=3133
const $mainToolbar = $("#main-toolbar");
const mainToolbar = $mainToolbar[0];
if (mainToolbar) {
Expand Down Expand Up @@ -209,7 +209,8 @@
if (targetWidth < minLPToolbarWidth) {
targetWidth = minLPToolbarWidth;
}
if (sidebarWidth + BAR_WIDTH + targetWidth + MIN_EDITOR_WIDTH > window.innerWidth) {
if (SidebarView.isVisible() &&
sidebarWidth + BAR_WIDTH + targetWidth + MIN_EDITOR_WIDTH > window.innerWidth) {
const trimmedSidebar = Math.max(30, window.innerWidth - BAR_WIDTH - targetWidth - MIN_EDITOR_WIDTH);
$sidebar.width(trimmedSidebar);
// jQuery .width() sidesteps Resizer — manually reposition its handle so
Expand Down
2 changes: 1 addition & 1 deletion src/view/WorkspaceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ define(function (require, exports, module) {
return;
}
var $sb = $("#sidebar");
if (!$sb.length || $sb[0].offsetWidth === 0) {
if (!$sb.length || !Resizer.isVisible($sb) || $sb[0].offsetWidth === 0) {
return;
}
var toolbarW = $mainToolbar.is(":visible") ? $mainToolbar.width() : 0;
Expand Down
30 changes: 30 additions & 0 deletions test/spec/CentralControlBar-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,36 @@ define(function (require, exports, module) {
SidebarView.show();
await awaitsFor(function () { return SidebarView.isVisible(); }, "sidebar to show again", 2000);
});

it("should keep the handle parked at the CCB edge when the layout is clamped while hidden",
async function () {
await openLivePreview();
SidebarView.hide();
await awaitsFor(function () { return !SidebarView.isVisible(); }, "sidebar to hide", 2000);

const toolbarWidth = _$("#main-toolbar").is(":visible") ? _$("#main-toolbar").width() : 0;
const maxSidebar = testWindow.innerWidth - CCB_WIDTH - toolbarWidth - 100;
const overLimitWidth = maxSidebar + 50;
expect(overLimitWidth).toBeLessThan(testWindow.innerWidth);
_$("#sidebar").width(overLimitWidth);

testWindow.dispatchEvent(new testWindow.Event("resize"));

const $resizer = _$(".main-view > .horz-resizer");
expect($resizer.length).toBe(1);
expect(Math.round($resizer[0].getBoundingClientRect().left)).toBe(CCB_WIDTH);
expect(_$("#sidebar")[0].offsetWidth).toBe(overLimitWidth);

SidebarView.show();
await awaitsFor(function () { return SidebarView.isVisible(); }, "sidebar to show again", 2000);
const sidebarWidth = _$("#sidebar")[0].offsetWidth;
expect(sidebarWidth).toBeLessThan(overLimitWidth);
const $shownResizer = _$("#sidebar > .horz-resizer");
expect(Math.round($shownResizer[0].getBoundingClientRect().left))
.toBe(sidebarWidth + CCB_WIDTH);

SidebarView.resize(200);
});
});

describe("2. CCB buttons", function () {
Expand Down
Loading