fix: scroll will stop halfway.

This commit is contained in:
linonetwo 2023-12-29 19:21:54 +08:00
parent 4724020772
commit 694cf46d49

View file

@ -43,7 +43,10 @@ export default function Preferences(): JSX.Element {
useEffect(() => {
const scrollTo = (window.meta() as IPossibleWindowMeta<WindowMeta[WindowNames.preferences]>).preferenceGotoTab;
if (scrollTo === undefined) return;
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 (