From 0ae63286d00f731b1e60b22337cf61dd4fe4414d Mon Sep 17 00:00:00 2001 From: Colt Coan <59135406+promptclickrun@users.noreply.github.com> Date: Sun, 29 Nov 2026 20:05:59 -0600 Subject: [PATCH] Stop Feed card bodies flickering between folded and open Body measured its Markdown inside the clipped box, so folding made it measure short, which unfolded it, which measured tall again: an endless layout loop. Keep the tallest height seen for the same text. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- mobile/src/features/today/Today.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mobile/src/features/today/Today.tsx b/mobile/src/features/today/Today.tsx index 3f99a228..e95233d5 100644 --- a/mobile/src/features/today/Today.tsx +++ b/mobile/src/features/today/Today.tsx @@ -112,12 +112,20 @@ function Byline({ bot, time, unread, note, hostLabel }: { bot?: Bot; time: numbe /** Markdown that folds to about four lines, with "More" when there is more. */ function Body({ text }: { text: string }) { const [open, setOpen] = useState(false); - const [height, setHeight] = useState(0); + // Text measures shorter once the fold clips it, so keep the tallest height seen for this + // text: otherwise the fold clips, measures short, unclips, measures tall, and loops. + const [measured, setMeasured] = useState({ text, height: 0 }); + const height = measured.text === text ? measured.height : 0; const long = height > BODY_CLIP + 8; + const onMeasure = (next: number) => + setMeasured((prev) => { + const base = prev.text === text ? prev.height : 0; + return next > base ? { text, height: next } : prev.text === text ? prev : { text, height: next }; + }); return ( - setHeight(event.nativeEvent.layout.height)}> + onMeasure(event.nativeEvent.layout.height)}>