From 21a73c463fb2151bc654eca8e588125d63381b05 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Tue, 2 Jul 2024 14:42:47 -0700 Subject: [PATCH] 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. --- core/comments/comment_view.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/comments/comment_view.ts b/core/comments/comment_view.ts index 006238db9..8fa3ea694 100644 --- a/core/comments/comment_view.ts +++ b/core/comments/comment_view.ts @@ -99,6 +99,9 @@ export class CommentView implements IRenderedElement { /** Whether this comment view has been disposed or not. */ private disposed = false; + /** Size of this comment when the resize drag was initiated. */ + private preResizeSize?: Size; + constructor(private readonly workspace: WorkspaceSvg) { this.svgRoot = dom.createSvgElement(Svg.G, { 'class': 'blocklyComment blocklyEditable', @@ -334,7 +337,7 @@ export class CommentView implements IRenderedElement { * elements to reflect the new size, and triggers size change listeners. */ setSize(size: Size) { - const oldSize = this.size; + const oldSize = this.preResizeSize || this.size; this.setSizeWithoutFiringEvents(size); this.onSizeChange(oldSize, this.size); } @@ -519,6 +522,8 @@ export class CommentView implements IRenderedElement { return; } + this.preResizeSize = this.getSize(); + // TODO(#7926): Move this into a utils file. this.workspace.startDrag( e, @@ -559,6 +564,7 @@ export class CommentView implements IRenderedElement { } // When ending a resize drag, notify size change listeners to fire an event. this.setSize(this.size); + this.preResizeSize = undefined; } /** Resizes the comment in response to a drag on the resize handle. */