Fix layout-shift in AI terminal — fixed-height scrollable body + auto-scroll
+26 / −22 filesscreenshot pending
Files changed
Diff
Lines reveal in sequence as you scroll. First 20 lines per file shown — expand for the rest.
src/marketing/components/ai-terminal.tsx+25 / −1tsx| @@ -35,13 +35,20 @@ export function AiTerminal({ entries }: Props) { | |
| const [paused, setPaused] = useState(false); | |
| const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null); | |
| const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null); | |
| + | const bodyRef = useRef<HTMLDivElement>(null); |
| const current = entries[index]; | |
| // Type out the current entry; advance to next when done. | |
| useEffect(() => { | |
| if (!current || paused) return; | |
| setShown(""); | |
| + | // New entry — reset scroll to top so the typewriter starts at the top |
| + | // of the fixed-height viewport rather than wherever the previous entry |
| + | // happened to land. |
| + | if (bodyRef.current) { |
| + | bodyRef.current.scrollTop = 0; |
| + | } |
| let i = 0; | |
| if (intervalRef.current) clearInterval(intervalRef.current); |