In /app use the window to scroll to initial read position

There isn't a scrollElementRef in `/app` because there is no
fixed header, so this will scroll the entire document instead.
This commit is contained in:
Jackson Harper 2022-03-16 12:47:24 -07:00
parent 88103cba9f
commit 463e569e57

View file

@ -151,7 +151,11 @@ export function Article(props: ArticleProps): JSX.Element {
return 0
}
props.scrollElementRef.current?.scroll(0, calculateOffset(anchorElement))
if (props.scrollElementRef.current) {
props.scrollElementRef.current?.scroll(0, calculateOffset(anchorElement))
} else {
window.document.documentElement.scroll(0, calculateOffset(anchorElement))
}
}
}, [
props.initialAnchorIndex,