Fix regression where Vello doesn't render new document opened after closing all documents (#3849)

* Fix regression where Vello doesn't render new document opened after closing all documents

* Remove last_svg_canvas and do this logic in the frontend
This commit is contained in:
Keavon Chambers
2026-03-05 09:54:31 +00:00
committed by GitHub
parent 8a1dfb9d8f
commit ead914ec2b
2 changed files with 8 additions and 12 deletions
@@ -185,9 +185,13 @@
const logicalWidth = parseFloat(foreignObject.getAttribute("width") || "0");
const logicalHeight = parseFloat(foreignObject.getAttribute("height") || "0");
// Clone canvas for repeated instances (layers that appear multiple times)
// Viewport canvas is marked with data-is-viewport and should never be cloned
// Viewport canvas is marked with data-is-viewport and should never be cloned.
// If it's already mounted in the viewport, skip the DOM replacement since it's already showing the rendered content.
// We check `canvas.isConnected` to ensure it's in the live DOM, not a detached tree from a destroyed component.
const isViewport = placeholder.hasAttribute("data-is-viewport");
if (isViewport && canvas.isConnected && canvas.parentElement?.closest("[data-viewport]")) return;
// Clone canvas for repeated instances (layers that appear multiple times)
if (!isViewport && canvas.parentElement) {
const newCanvas = window.document.createElement("canvas");
const context = newCanvas.getContext("2d");