From 3bbc9effa39a10feb4155e0e1d57beff33b550af Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 12 Nov 2024 10:00:42 -0500 Subject: [PATCH] fix(docs): scroll to top after navigate --- packages/documentation-framework/components/link/link.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/documentation-framework/components/link/link.js b/packages/documentation-framework/components/link/link.js index c6102274e7..e2ad64771e 100644 --- a/packages/documentation-framework/components/link/link.js +++ b/packages/documentation-framework/components/link/link.js @@ -48,9 +48,12 @@ export const Link = ({ href, to, onMouseOver = () => {}, onClick, ...props }) => if (!(ev.ctrlKey || ev.metaKey)) { // avoid disallowing cmnd/ctrl+click opening in new tab ev.preventDefault(); - document.querySelector('#ws-page-main').scrollTo({ top: 0 }); // scroll to top of page if (typeof window !== 'undefined' && url !== location.pathname) { - Promiseany([preloadPromise, new Promise((res) => setTimeout(res, 500))]).then(() => navigate(url)); + Promiseany([preloadPromise, new Promise((res) => setTimeout(res, 500))]) + .then(() => navigate(url)) + .then(() => { + document.querySelector('#ws-page-main').scrollTo({ top: 0 }); // scroll to top of page + }); } } };