diff --git a/app/w/components/blocks/components/workflow-block/sub-block/components/code.tsx b/app/w/components/blocks/components/workflow-block/sub-block/components/code.tsx index cb08a1c547..f490e5655b 100644 --- a/app/w/components/blocks/components/workflow-block/sub-block/components/code.tsx +++ b/app/w/components/blocks/components/workflow-block/sub-block/components/code.tsx @@ -80,6 +80,8 @@ export function Code() { const contentWrapperRef = useRef(null) const [contentWidth, setContentWidth] = useState(0) const [maxLineWidth, setMaxLineWidth] = useState(0) + const [containerWidth, setContainerWidth] = useState(0) + const containerRef = useRef(null) useEffect(() => { if (!contentWrapperRef.current) return @@ -94,6 +96,19 @@ export function Code() { return () => resizeObserver.disconnect() }, []) + useEffect(() => { + if (!containerRef.current) return + + const resizeObserver = new ResizeObserver((entries) => { + for (const entry of entries) { + setContainerWidth(entry.contentRect.width) + } + }) + + resizeObserver.observe(containerRef.current) + return () => resizeObserver.disconnect() + }, []) + // Update scroll handler to sync textareas with container const handleContainerScroll = useCallback( (e: React.UIEvent) => { @@ -539,6 +554,7 @@ export function Code() { return (
@@ -553,7 +569,11 @@ export function Code() { className="overflow-auto scrollbar-hide h-full" onScroll={handleContainerScroll} style={{ - maxWidth: `${Math.max(maxLineWidth + 35, contentWidth)}px`, + maxWidth: `${Math.max( + maxLineWidth + 35, + contentWidth, + containerWidth + )}px`, }} >
@@ -562,7 +582,11 @@ export function Code() { key={line.id} className="flex pl-8 w-fit" style={{ - width: `${Math.max(maxLineWidth + 35, contentWidth)}px`, + width: `${Math.max( + maxLineWidth + 35, + contentWidth, + containerWidth + )}px`, }} >