From 08bf5e9caf48a4a1c49d126bfeabad2b8b5855f6 Mon Sep 17 00:00:00 2001 From: NineKey Date: Sun, 13 Sep 2026 00:03:32 +0800 Subject: [PATCH] Clamp runaway Dynamic Tag node height --- web/dynamic_loader.js | 5 +---- web/dynamic_utils.js | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/web/dynamic_loader.js b/web/dynamic_loader.js index 2ce0442..acb6196 100644 --- a/web/dynamic_loader.js +++ b/web/dynamic_loader.js @@ -1019,14 +1019,11 @@ app.registerExtension({ } }); - requestAnimationFrame(() => { - node.triggerAutoSize(); - }); - } catch (e) { console.error("Error restoring tags:", e); } } + requestAnimationFrame(() => node.triggerAutoSize()); }); return r; diff --git a/web/dynamic_utils.js b/web/dynamic_utils.js index 46acec3..5b7325a 100644 --- a/web/dynamic_utils.js +++ b/web/dynamic_utils.js @@ -59,6 +59,9 @@ export function getDynamicGroupMenu(index, totalLength, moveCallback, moveAbsCal * 2. 防止新增項目時擠壓現有組件 (Growth Logic) */ export function setupSizeManager(node) { + const MAX_RESTORED_EXTRA_HEIGHT = 480; + const MAX_RESTORED_HEIGHT = 900; + const initialMinHeight = node.computeSize?.()[1] || 0; node._userMinHeight = 0; node._isResizing = false; @@ -67,7 +70,15 @@ export function setupSizeManager(node) { node.onConfigure = function(data) { if (originalOnConfigure) originalOnConfigure.apply(this, arguments); if (data && data.size) { - node._userMinHeight = data.size[1]; + const restoredHeight = data.size[1]; + const runawayHeight = restoredHeight > MAX_RESTORED_HEIGHT + && restoredHeight > initialMinHeight + MAX_RESTORED_EXTRA_HEIGHT; + node._userMinHeight = runawayHeight ? 0 : restoredHeight; + if (runawayHeight) { + node._isResizing = true; + node.setSize([node.size[0], initialMinHeight]); + node._isResizing = false; + } } }; @@ -133,7 +144,13 @@ export function setupSizeManager(node) { */ node.triggerAutoSize = function() { const contentMinHeight = node.computeSize()[1]; - const targetHeight = Math.max(contentMinHeight, node._userMinHeight || 0); + const restoredHeight = node._userMinHeight || 0; + const runawayHeight = restoredHeight > MAX_RESTORED_HEIGHT + && restoredHeight > contentMinHeight + MAX_RESTORED_EXTRA_HEIGHT; + const targetHeight = runawayHeight + ? contentMinHeight + : Math.max(contentMinHeight, restoredHeight); + if (runawayHeight) node._userMinHeight = targetHeight; node._isResizing = true; node.setSize([node.size[0], targetHeight]); @@ -141,4 +158,4 @@ export function setupSizeManager(node) { node.setDirtyCanvas(true, true); }; -} \ No newline at end of file +}