From 9eb40d165ffe61aff11b04a02156b50a9a537443 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 18 Dec 2022 13:43:34 +0800 Subject: [PATCH] Only snap to top when there are ancestors --- src/pages/status.jsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index e2f3a9ba..ddc9d932 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -94,10 +94,13 @@ function StatusPage({ id }) { }, [id]); useLayoutEffect(() => { - heroStatusRef.current?.scrollIntoView({ - // behavior: 'smooth', - block: 'start', - }); + const hasAncestor = statuses.some((s) => s.ancestor); + if (hasAncestor) { + heroStatusRef.current?.scrollIntoView({ + // behavior: 'smooth', + block: 'start', + }); + } }, [statuses]); const heroStatus = states.statuses.get(id);