Comfy-Org / Comfy-Org/ComfyUI_frontend

refactor: move useCanvasStore() inside isCollapsed guard in syncNodeSlotLayoutsFromDOM

Open
#10,792 0 comments 0 reactions 1 assignee Claimed by @DrJKL View on GitHub
developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Summary

In `src/renderer/extensions/vueNodes/composables/useSlotElementTracking.ts`, `useCanvasStore()` is currently called on every `syncNodeSlotLayoutsFromDOM` invocation regardless of whether the node is collapsed. Since `conv` (the canvas position conversion helper) is only used when `isCollapsed` is `true`, the store lookup should be moved inside the `isCollapsed` guard to keep the code semantically clean.

## Suggested change

```ts
const conv = isCollapsed
? (useCanvasStore().canvas ? useSharedCanvasPositionConversion() : null)
: null
```

## Context

- Raised in PR #10641 (fix: collapsed node connection link positions): https://github.com/Comfy-Org/ComfyUI_frontend/pull/10641#discussion_r3011997727
- While `useCanvasStore()` is a cheap Pinia singleton call, scoping it to the collapsed branch improves readability and makes the intent explicit.

## References
- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10641
- Comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10641#discussion_r3011997727

Requested by @DrJKL

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-10792-refactor-move-useCanvasStore-inside-isCollapsed-guard-in-syncNodeSlotLayoutsFromDO-3356d73d3650814ebd7de210c34effec) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.