From 694cf46d4903744e0de8253f2c2b79bc0f9c03b9 Mon Sep 17 00:00:00 2001 From: linonetwo Date: Fri, 29 Dec 2023 19:21:54 +0800 Subject: [PATCH] fix: scroll will stop halfway. --- src/pages/Preferences/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/Preferences/index.tsx b/src/pages/Preferences/index.tsx index 1a7ea784..8a5eb31e 100644 --- a/src/pages/Preferences/index.tsx +++ b/src/pages/Preferences/index.tsx @@ -43,7 +43,10 @@ export default function Preferences(): JSX.Element { useEffect(() => { const scrollTo = (window.meta() as IPossibleWindowMeta).preferenceGotoTab; if (scrollTo === undefined) return; - sections[scrollTo].ref?.current?.scrollIntoView({ behavior: 'smooth', block: 'start' }); + setTimeout(() => { + // wait 100ms so page anchors are all loaded. Otherwise scroll will stop halfway. + sections[scrollTo].ref?.current?.scrollIntoView({ behavior: 'smooth', block: 'start' }); + }, 100); }, [sections]); return (