[backport cloud/1.38] fix: add null check in getCanvasCenter to prevent crash on asset insert (#8404)

Backport of #8399 to `cloud/1.38`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8404-backport-cloud-1-38-fix-add-null-check-in-getCanvasCenter-to-prevent-crash-on-asset-in-2f76d73d365081de80dac9abcc3c53b5)
by [Unito](https://www.unito.io)

Co-authored-by: Jin Yi <jin12cc@gmail.com>
This commit is contained in:
Comfy Org PR Bot
2026-01-29 13:45:03 +09:00
committed by GitHub
parent dd0b2dc9cb
commit 3060423e27

View File

@@ -876,7 +876,11 @@ export const useLitegraphService = () => {
function getCanvasCenter(): Point {
const dpi = Math.max(window.devicePixelRatio ?? 1, 1)
const [x, y, w, h] = app.canvas.ds.visible_area
const visibleArea = app.canvas?.ds?.visible_area
if (!visibleArea) {
return [0, 0]
}
const [x, y, w, h] = visibleArea
return [x + w / dpi / 2, y + h / dpi / 2]
}