From 7b1ff0d05558a231c57d7d49f3c28ff389cf7a98 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 11:48:50 -0700 Subject: [PATCH] Move mobile connection log scroll into content handler (#3402) --- mobile/src/components/ConnectionLog.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mobile/src/components/ConnectionLog.tsx b/mobile/src/components/ConnectionLog.tsx index 3722ba0db..afe07503c 100644 --- a/mobile/src/components/ConnectionLog.tsx +++ b/mobile/src/components/ConnectionLog.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from 'react' +import { useRef } from 'react' import { ScrollView, StyleSheet, Text, View } from 'react-native' import type { ConnectionLogEntry } from '../transport/types' import { colors, radii, spacing, typography } from '../theme/mobile-theme' @@ -36,14 +36,6 @@ function formatTime(ts: number, baseTs: number): string { export function ConnectionLog({ entries, title }: Props) { const scrollRef = useRef(null) - // Why: keep the latest entry visible while logs grow during a slow - // connect. Skip on empty so the title row doesn't jump. - useEffect(() => { - if (entries.length === 0) return - const id = setTimeout(() => scrollRef.current?.scrollToEnd({ animated: true }), 16) - return () => clearTimeout(id) - }, [entries.length]) - if (entries.length === 0) return null const baseTs = entries[0]!.ts @@ -55,6 +47,7 @@ export function ConnectionLog({ entries, title }: Props) { style={styles.scroll} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false} + onContentSizeChange={() => scrollRef.current?.scrollToEnd({ animated: true })} > {entries.map((entry) => (