From 75938b32a1ee6ae12fcc7f245e2400ea3411c40c Mon Sep 17 00:00:00 2001 From: bananasss00 Date: Wed, 4 Dec 2024 22:53:20 +0300 Subject: [PATCH] fix issue https://github.com/coolzilj/ComfyUI-Photopea/issues/5 credits: https://github.com/ltdrdata/ComfyUI-Impact-Pack/blob/348c3dcb6b3f9e5fe42f184a01df0bb22b7bfc8d/js/impact-sam-editor.js#L279 --- js/photopea-editor.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/photopea-editor.js b/js/photopea-editor.js index bf763ff..4563d0f 100644 --- a/js/photopea-editor.js +++ b/js/photopea-editor.js @@ -116,6 +116,22 @@ class LJPhotopeaEditorDialog extends ComfyDialog { bottom_panel.appendChild(self.fullscreenButton); bottom_panel.appendChild(self.saveButton); bottom_panel.appendChild(cancelButton); + + // replacement of onClose hook since close is not real close + const observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.type === 'attributes' && mutation.attributeName === 'style') { + if(self.last_display_style && self.last_display_style != 'none' && self.element.style.display == 'none') { + ComfyApp.onClipspaceEditorClosed(); + } + + self.last_display_style = self.element.style.display; + } + }); + }); + + const config = { attributes: true }; + observer.observe(this.element, config); } show() {