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
4 changes: 2 additions & 2 deletions packages/blockly/core/toolbox/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,13 @@ export class Toolbox
this.toolboxPosition === toolbox.Position.LEFT
? workspace.scrollX +
rect.width +
(flyout?.isVisible() ? flyout.getWidth() : 0)
(flyout && !flyout.autoClose ? flyout.getWidth() : 0)
: workspace.scrollX;
const newY =
this.toolboxPosition === toolbox.Position.TOP
? workspace.scrollY +
rect.height +
(flyout?.isVisible() ? flyout.getHeight() : 0)
(flyout && !flyout.autoClose ? flyout.getHeight() : 0)
: workspace.scrollY;
workspace.translate(newX, newY);

Expand Down
17 changes: 17 additions & 0 deletions packages/blockly/tests/mocha/toolbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,23 @@ suite('Toolbox', function () {
assert.isFalse(this.parentCategory.isExpanded());
assert.isFalse(this.flyout.isVisible());
});
test('resizing a toolbox item with an auto-closing flyout visible should not offset the workspace by the flyout size', function () {
clickCategory(this.parentCategory);
assert.isTrue(this.flyout.isVisible());
assert.isAbove(this.flyout.getWidth(), 0);

const workspace = this.toolbox.workspace_;
const translateSpy = sinon.spy(workspace, 'translate');
this.toolbox.handleToolboxItemResize();

const expectedX =
workspace.scrollX +
this.toolbox.HtmlDiv.getBoundingClientRect().width;
assert.deepEqual(translateSpy.firstCall.args, [
expectedX,
workspace.scrollY,
]);
});
});
});

Expand Down
Loading