diff --git a/core/insertion_marker_manager.ts b/core/insertion_marker_manager.ts index 016d76b90e3..b55c75d2173 100644 --- a/core/insertion_marker_manager.ts +++ b/core/insertion_marker_manager.ts @@ -25,6 +25,7 @@ import type {IDragTarget} from './interfaces/i_drag_target.js'; import type {RenderedConnection} from './rendered_connection.js'; import type {Coordinate} from './utils/coordinate.js'; import type {WorkspaceSvg} from './workspace_svg.js'; +import * as renderManagement from './render_management.js'; /** Represents a nearby valid connection. */ interface CandidateConnection { @@ -608,18 +609,17 @@ export class InsertionMarkerManager { // Render disconnected from everything else so that we have a valid // connection location. - insertionMarker.render(); - insertionMarker.rendered = true; - insertionMarker.getSvgRoot().setAttribute('visibility', 'visible'); + insertionMarker.queueRender(); + renderManagement.triggerQueuedRenders(); - if (imConn && closest) { - // Position so that the existing block doesn't move. - insertionMarker.positionNearConnection(imConn, closest); - } - if (closest) { - // Connect() also renders the insertion marker. - imConn.connect(closest); - } + // Position so that the existing block doesn't move. + insertionMarker.positionNearConnection(imConn, closest); + // Connect() also renders the insertion marker. + imConn.connect(closest); + + renderManagement.finishQueuedRenders().then(() => { + insertionMarker?.getSvgRoot().setAttribute('visibility', 'visible'); + }); this.markerConnection = imConn; } diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 443249c8f1f..f269fa4502f 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -77,6 +77,7 @@ import {WorkspaceCommentSvg} from './workspace_comment_svg.js'; import * as Xml from './xml.js'; import {ZoomControls} from './zoom_controls.js'; import {ContextMenuOption} from './contextmenu_registry.js'; +import * as renderManagement from './render_management.js'; /** Margin around the top/bottom/left/right after a zoomToFit call. */ const ZOOM_TO_FIT_MARGIN = 20; @@ -1251,11 +1252,13 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { if (this.currentGesture_) { const imList = this.currentGesture_.getInsertionMarkers(); for (let i = 0; i < imList.length; i++) { - imList[i].render(false); + imList[i].queueRender(); } } - this.markerManager.updateMarkers(); + renderManagement + .finishQueuedRenders() + .then(() => void this.markerManager.updateMarkers()); } /**