-
Notifications
You must be signed in to change notification settings - Fork 498
fix: sync node.imgs on image load for VueNodes context menu #7742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,6 +198,8 @@ const handleImageLoad = (event: Event) => { | |
| if (img.naturalWidth && img.naturalHeight) { | ||
| actualDimensions.value = `${img.naturalWidth} x ${img.naturalHeight}` | ||
| } | ||
|
|
||
| syncNodeImgs() | ||
| } | ||
|
|
||
| const handleImageError = () => { | ||
|
|
@@ -207,14 +209,21 @@ const handleImageError = () => { | |
| actualDimensions.value = null | ||
| } | ||
|
|
||
| // In vueNodes mode, we need to set them manually before opening the mask editor. | ||
| const setupNodeForMaskEditor = () => { | ||
| // Sync node.imgs so context menu can detect this as an image node | ||
| const syncNodeImgs = () => { | ||
| if (!props.nodeId || !currentImageEl.value) return | ||
| const node = app.rootGraph?.getNodeById(props.nodeId) | ||
| if (!node) return | ||
| node.imageIndex = currentIndex.value | ||
| node.imgs = [currentImageEl.value] | ||
| app.canvas?.select(node) | ||
| } | ||
|
|
||
| // In vueNodes mode, we need to set them manually before opening the mask editor. | ||
| const setupNodeForMaskEditor = () => { | ||
| syncNodeImgs() | ||
| if (!props.nodeId) return | ||
| const node = app.rootGraph?.getNodeById(props.nodeId) | ||
| if (node) app.canvas?.select(node) | ||
| } | ||
|
Comment on lines
+221
to
227
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Optional: Streamline to use returned node. If you adopt the optional refactor from the previous comment (having Proposed simplification const setupNodeForMaskEditor = () => {
- syncNodeImgs()
- if (!props.nodeId) return
- const node = app.rootGraph?.getNodeById(props.nodeId)
+ const node = syncNodeImgs()
if (node) app.canvas?.select(node)
}This eliminates the duplicate
🤖 Prompt for AI Agents |
||
|
|
||
| const handleEditMask = () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Well-structured extraction for reusability.
Good separation of concerns—
syncNodeImgsupdates node state without coupling to canvas selection. This makes the logic reusable in both image load and mask editor setup paths.Optional: Return the node to avoid duplicate lookups
Currently,
setupNodeForMaskEditorcallssyncNodeImgs()and then separately callsgetNodeByIdagain. You could havesyncNodeImgsreturn the node to eliminate the duplicate lookup:const syncNodeImgs = () => { if (!props.nodeId || !currentImageEl.value) return const node = app.rootGraph?.getNodeById(props.nodeId) if (!node) return node.imageIndex = currentIndex.value node.imgs = [currentImageEl.value] + return node }Then update
setupNodeForMaskEditoraccordingly (see next comment).📝 Committable suggestion
🤖 Prompt for AI Agents