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);