@@ -125,7 +125,7 @@ export class CommentView implements IRenderedElement {
125125 workspace . getLayerManager ( ) ?. append ( this , layers . BLOCK ) ;
126126
127127 // Set size to the default size.
128- this . setSize ( this . size ) ;
128+ this . setSizeWithoutFiringEvents ( this . size ) ;
129129
130130 // Set default transform (including inverted scale for RTL).
131131 this . moveTo ( new Coordinate ( 0 , 0 ) ) ;
@@ -298,7 +298,7 @@ export class CommentView implements IRenderedElement {
298298 * Sets the size of the comment in workspace units, and updates the view
299299 * elements to reflect the new size.
300300 */
301- setSize ( size : Size ) {
301+ setSizeWithoutFiringEvents ( size : Size ) {
302302 const topBarSize = this . topBarBackground . getBBox ( ) ;
303303 const deleteSize = this . deleteIcon . getBBox ( ) ;
304304 const foldoutSize = this . foldoutIcon . getBBox ( ) ;
@@ -309,7 +309,6 @@ export class CommentView implements IRenderedElement {
309309 size ,
310310 this . calcMinSize ( topBarSize , foldoutSize , deleteSize ) ,
311311 ) ;
312- const oldSize = this . size ;
313312 this . size = size ;
314313
315314 this . svgRoot . setAttribute ( 'height' , `${ size . height } ` ) ;
@@ -328,7 +327,15 @@ export class CommentView implements IRenderedElement {
328327 resizeSize ,
329328 ) ;
330329 this . updateResizeHandlePosition ( size , resizeSize ) ;
330+ }
331331
332+ /**
333+ * Sets the size of the comment in workspace units, updates the view
334+ * elements to reflect the new size, and triggers size change listeners.
335+ */
336+ setSize ( size : Size ) {
337+ const oldSize = this . size ;
338+ this . setSizeWithoutFiringEvents ( size ) ;
332339 this . onSizeChange ( oldSize , this . size ) ;
333340 }
334341
@@ -472,7 +479,7 @@ export class CommentView implements IRenderedElement {
472479
473480 /**
474481 * Triggers listeners when the size of the comment changes, either
475- * progrmatically or manually by the user.
482+ * programmatically or manually by the user.
476483 */
477484 private onSizeChange ( oldSize : Size , newSize : Size ) {
478485 // Loop through listeners backwards in case they remove themselves.
@@ -550,13 +557,17 @@ export class CommentView implements IRenderedElement {
550557 browserEvents . unbind ( this . resizePointerMoveListener ) ;
551558 this . resizePointerMoveListener = null ;
552559 }
560+ // When ending a resize drag, notify size change listeners to fire an event.
561+ this . setSize ( this . size ) ;
553562 }
554563
555564 /** Resizes the comment in response to a drag on the resize handle. */
556565 private onResizePointerMove ( e : PointerEvent ) {
557566 // TODO(#7926): Move this into a utils file.
558- const delta = this . workspace . moveDrag ( e ) ;
559- this . setSize ( new Size ( this . workspace . RTL ? - delta . x : delta . x , delta . y ) ) ;
567+ const size = this . workspace . moveDrag ( e ) ;
568+ this . setSizeWithoutFiringEvents (
569+ new Size ( this . workspace . RTL ? - size . x : size . x , size . y ) ,
570+ ) ;
560571 }
561572
562573 /** Returns true if the comment is currently collapsed. */
@@ -573,7 +584,7 @@ export class CommentView implements IRenderedElement {
573584 dom . removeClass ( this . svgRoot , 'blocklyCollapsed' ) ;
574585 }
575586 // Repositions resize handle and such.
576- this . setSize ( this . size ) ;
587+ this . setSizeWithoutFiringEvents ( this . size ) ;
577588 this . onCollapse ( ) ;
578589 }
579590
@@ -682,7 +693,7 @@ export class CommentView implements IRenderedElement {
682693
683694 /**
684695 * Triggers listeners when the text of the comment changes, either
685- * progrmatically or manually by the user.
696+ * programmatically or manually by the user.
686697 */
687698 private onTextChange ( ) {
688699 const oldText = this . text ;
0 commit comments