From 4ef7f2d8c408e11f25d2d8a789a2382379490fea Mon Sep 17 00:00:00 2001 From: Raykosan <71210053+Raykosan@users.noreply.github.com> Date: Wed, 26 Aug 2026 05:59:11 +0300 Subject: [PATCH] Added RS Label node --- web/rs_label.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/web/rs_label.js b/web/rs_label.js index c96761e..aa86be2 100644 --- a/web/rs_label.js +++ b/web/rs_label.js @@ -229,9 +229,7 @@ app.registerExtension({ }; nodeType.prototype.showSettingsDialog = async function() { - if (this.dialogOpen) { - return; - } + if (this.dialogOpen) return; if (this._fontLoadPromise) { try { await this._fontLoadPromise; } catch (e) {} @@ -290,10 +288,32 @@ app.registerExtension({ if (isDragging) { isDragging = false; title.style.cursor = "grab"; } }); - // FIX: Убран window.blur, оставлен только visibilitychange и Escape + // FIX: Перехват History API для отслеживания навигации ComfyUI + const originalPushState = history.pushState; + const originalReplaceState = history.replaceState; + + const onNavigate = () => { + closeDialog(); + }; + + history.pushState = function(...args) { + originalPushState.apply(this, args); + onNavigate(); + }; + + history.replaceState = function(...args) { + originalReplaceState.apply(this, args); + onNavigate(); + }; + const closeDialog = () => { + // Восстанавливаем оригинальные методы History API + history.pushState = originalPushState; + history.replaceState = originalReplaceState; + document.removeEventListener("keydown", escHandler); document.removeEventListener("visibilitychange", visibilityHandler); + window.removeEventListener("hashchange", onHashChange); if (dialog.parentNode) document.body.removeChild(dialog); this.dialogOpen = false; this.setDirtyCanvas(true, true); @@ -307,6 +327,13 @@ app.registerExtension({ }; document.addEventListener("visibilitychange", visibilityHandler); + // Оставляем hashchange как запасной вариант + const currentHash = window.location.hash; + const onHashChange = () => { + if (window.location.hash !== currentHash) closeDialog(); + }; + window.addEventListener("hashchange", onHashChange); + const createRow = (label, createControl) => { const row = document.createElement("div"); row.style.display = "flex";