diff --git a/web/scripts/app.js b/web/scripts/app.js index b980e2882..3cbd8eb9a 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -1109,7 +1109,7 @@ export class ComfyApp { // Save current workflow automatically setInterval(() => { - if (document.visibilityState === "visible") { + if (document.hasFocus()) { localStorage.setItem("workflow", JSON.stringify(this.graph.serialize())); } }, 1000); diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 33aed7e72..68de5a67d 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -778,10 +778,8 @@ export class ComfyUI { this.is_launchTiming = true; this.switch_workflow_combo = document.getElementById("comfy-switch-workflow-combo"); - document.addEventListener("visibilitychange", () => { - if (document.visibilityState === "visible") { - localStorage.setItem("workflow_current_id", this.switch_workflow_combo.selectedIndex); - } + window.addEventListener("focus", () => { + localStorage.setItem("workflow_current_id", this.switch_workflow_combo.selectedIndex); }); const id_renameWorkflow = "Comfy.RenameWorkflowDialog";