From 463e569e57f5d5935201b29d9dc749b23b43e6a6 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 16 Mar 2022 12:47:24 -0700 Subject: [PATCH] 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. --- packages/web/components/templates/article/Article.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/web/components/templates/article/Article.tsx b/packages/web/components/templates/article/Article.tsx index ded8f2a4c..60bbe1ff1 100644 --- a/packages/web/components/templates/article/Article.tsx +++ b/packages/web/components/templates/article/Article.tsx @@ -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,