From fcdeb6ff6f48e77b3d4b41813dbc4db107562ce5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Mar 2026 23:51:01 +0000 Subject: [PATCH] Fix node height growing on remount with onlyRenderVisibleElements When a node with inline parameters scrolls off-screen, React Flow unmounts it, resetting trackedSettingsHeightRef to 0. On remount the expand effect would add the panel height to the node again, even though it was already included. Skip the expand animation on initial mount and just sync the tracked ref from the DOM instead. https://claude.ai/code/session_01MvD1n4QeXutgwUpKJuDGHa --- src/components/nodes/BaseNode.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/nodes/BaseNode.tsx b/src/components/nodes/BaseNode.tsx index d5373219..e5f1cca1 100644 --- a/src/components/nodes/BaseNode.tsx +++ b/src/components/nodes/BaseNode.tsx @@ -80,9 +80,21 @@ export function BaseNode({ const trackedSettingsHeightRef = useRef(0); const isAnimatingRef = useRef(false); const animationTimeoutRef = useRef | null>(null); + const isInitialMountRef = useRef(true); // Adjust node height when settings expand or collapse useLayoutEffect(() => { + // On initial mount with settings already expanded (e.g. remount after + // onlyRenderVisibleElements), the node height already includes the panel. + // Just sync the tracked ref without adding height again. + if (isInitialMountRef.current) { + isInitialMountRef.current = false; + if (settingsExpanded && settingsPanelRef.current) { + trackedSettingsHeightRef.current = settingsPanelRef.current.offsetHeight; + } + return; + } + // Cancel any pending animation timeout from a previous toggle (handles rapid toggling) if (animationTimeoutRef.current) { clearTimeout(animationTimeoutRef.current);