Only snap to top when there are ancestors

This commit is contained in:
Lim Chee Aun 2022-12-18 13:43:34 +08:00
parent 762e525c68
commit 9eb40d165f

View file

@ -94,10 +94,13 @@ function StatusPage({ id }) {
}, [id]); }, [id]);
useLayoutEffect(() => { useLayoutEffect(() => {
heroStatusRef.current?.scrollIntoView({ const hasAncestor = statuses.some((s) => s.ancestor);
// behavior: 'smooth', if (hasAncestor) {
block: 'start', heroStatusRef.current?.scrollIntoView({
}); // behavior: 'smooth',
block: 'start',
});
}
}, [statuses]); }, [statuses]);
const heroStatus = states.statuses.get(id); const heroStatus = states.statuses.get(id);