Comfy-Org / Comfy-Org/ComfyUI_frontend
refactor: move useCanvasStore() inside isCollapsed guard in syncNodeSlotLayoutsFromDOM
- 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
Assessment
This issue has not been assessed yet.