Skip to content

Commit

Permalink
Hint for empty canvas when invoking Comfy.Canvas.FitView (#1826)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Dec 6, 2024
1 parent a6549fb commit 6409e17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
"@comfyorg/comfyui-electron-types": "^0.3.25",
"@comfyorg/litegraph": "^0.8.43",
"@comfyorg/litegraph": "^0.8.44",
"@primevue/themes": "^4.0.5",
"@vueuse/core": "^11.0.0",
"@xterm/addon-fit": "^0.10.0",
Expand Down
12 changes: 11 additions & 1 deletion src/hooks/coreCommandHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,17 @@ export function useCoreCommands(): ComfyCommand[] {
id: 'Comfy.Canvas.FitView',
icon: 'pi pi-expand',
label: 'Fit view to selected nodes',
function: () => app.canvas.fitViewToSelectionAnimated()
function: () => {
if (app.canvas.empty) {
useToastStore().add({
severity: 'error',
summary: 'Empty canvas',
life: 3000
})
return
}
app.canvas.fitViewToSelectionAnimated()
}
},
{
id: 'Comfy.Canvas.ToggleLock',
Expand Down

0 comments on commit 6409e17

Please sign in to comment.