mirror of
https://github.com/google/blockly.git
synced 2026-01-11 02:47:09 +01:00
fix: comment size not respecting collapsed-ness (#8136)
* fix: comment size not respecting collapsed-ness * chore: fix tests the only way I know how, by adding explicit clock ticks
This commit is contained in:
@@ -286,9 +286,12 @@ export class CommentView implements IRenderedElement {
|
||||
return this.svgRoot;
|
||||
}
|
||||
|
||||
/** Returns the current size of the comment in workspace units. */
|
||||
/**
|
||||
* Returns the current size of the comment in workspace units.
|
||||
* Respects collapsing.
|
||||
*/
|
||||
getSize(): Size {
|
||||
return this.size;
|
||||
return this.collapsed ? this.topBarBackground.getBBox() : this.size;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -120,10 +120,21 @@ export class RenderedWorkspaceComment
|
||||
return this.view.getSvgRoot();
|
||||
}
|
||||
|
||||
/** Returns the bounding rectangle of this comment in workspace coordinates. */
|
||||
/**
|
||||
* Returns the comment's size in workspace units.
|
||||
* Does not respect collapsing.
|
||||
*/
|
||||
getSize(): Size {
|
||||
return super.getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounding rectangle of this comment in workspace coordinates.
|
||||
* Respects collapsing.
|
||||
*/
|
||||
getBoundingRectangle(): Rect {
|
||||
const loc = this.getRelativeToSurfaceXY();
|
||||
const size = this.getSize();
|
||||
const size = this.view.getSize();
|
||||
let left;
|
||||
let right;
|
||||
if (this.workspace.RTL) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
|
||||
suite('Workspace comment', function () {
|
||||
setup(function () {
|
||||
sharedTestSetup.call(this);
|
||||
this.clock = sharedTestSetup.call(this, {fireEventsNow: false}).clock;
|
||||
this.workspace = new Blockly.inject('blocklyDiv', {});
|
||||
});
|
||||
|
||||
@@ -31,6 +31,8 @@ suite('Workspace comment', function () {
|
||||
this.workspace,
|
||||
);
|
||||
|
||||
this.clock.runAll();
|
||||
|
||||
assertEventFired(
|
||||
spy,
|
||||
Blockly.Events.CommentCreate,
|
||||
@@ -47,6 +49,8 @@ suite('Workspace comment', function () {
|
||||
|
||||
this.renderedComment.dispose();
|
||||
|
||||
this.clock.runAll();
|
||||
|
||||
assertEventFired(
|
||||
spy,
|
||||
Blockly.Events.CommentDelete,
|
||||
@@ -63,6 +67,8 @@ suite('Workspace comment', function () {
|
||||
|
||||
this.renderedComment.moveTo(new Blockly.utils.Coordinate(42, 42));
|
||||
|
||||
this.clock.runAll();
|
||||
|
||||
assertEventFired(
|
||||
spy,
|
||||
Blockly.Events.CommentMove,
|
||||
@@ -83,6 +89,8 @@ suite('Workspace comment', function () {
|
||||
|
||||
this.renderedComment.setText('test text');
|
||||
|
||||
this.clock.runAll();
|
||||
|
||||
assertEventFired(
|
||||
spy,
|
||||
Blockly.Events.CommentChange,
|
||||
@@ -103,6 +111,8 @@ suite('Workspace comment', function () {
|
||||
|
||||
this.renderedComment.setCollapsed(true);
|
||||
|
||||
this.clock.runAll();
|
||||
|
||||
assertEventFired(
|
||||
spy,
|
||||
Blockly.Events.CommentCollapse,
|
||||
@@ -123,6 +133,8 @@ suite('Workspace comment', function () {
|
||||
|
||||
this.renderedComment.setCollapsed(false);
|
||||
|
||||
this.clock.runAll();
|
||||
|
||||
assertEventFired(
|
||||
spy,
|
||||
Blockly.Events.CommentCollapse,
|
||||
|
||||
Reference in New Issue
Block a user