Skip to content

Commit 21a73c4

Browse files
authored
fix: correctly report the pre-resize-drag size to workspace comment size change listeners (#8240)
* fix: correctly report the pre-resize-drag size to workspace comment size change listeners * chore: run formatter * refactor: implicitly use the presence of preResizeSize to identify a drag.
1 parent e01154c commit 21a73c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/comments/comment_view.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ export class CommentView implements IRenderedElement {
9999
/** Whether this comment view has been disposed or not. */
100100
private disposed = false;
101101

102+
/** Size of this comment when the resize drag was initiated. */
103+
private preResizeSize?: Size;
104+
102105
constructor(private readonly workspace: WorkspaceSvg) {
103106
this.svgRoot = dom.createSvgElement(Svg.G, {
104107
'class': 'blocklyComment blocklyEditable',
@@ -334,7 +337,7 @@ export class CommentView implements IRenderedElement {
334337
* elements to reflect the new size, and triggers size change listeners.
335338
*/
336339
setSize(size: Size) {
337-
const oldSize = this.size;
340+
const oldSize = this.preResizeSize || this.size;
338341
this.setSizeWithoutFiringEvents(size);
339342
this.onSizeChange(oldSize, this.size);
340343
}
@@ -519,6 +522,8 @@ export class CommentView implements IRenderedElement {
519522
return;
520523
}
521524

525+
this.preResizeSize = this.getSize();
526+
522527
// TODO(#7926): Move this into a utils file.
523528
this.workspace.startDrag(
524529
e,
@@ -559,6 +564,7 @@ export class CommentView implements IRenderedElement {
559564
}
560565
// When ending a resize drag, notify size change listeners to fire an event.
561566
this.setSize(this.size);
567+
this.preResizeSize = undefined;
562568
}
563569

564570
/** Resizes the comment in response to a drag on the resize handle. */

0 commit comments

Comments
 (0)