Skip to content

Commit

Permalink
fix(docs): scroll to top after navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
evwilkin committed Nov 12, 2024
1 parent deaeb30 commit 3bbc9ef
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/documentation-framework/components/link/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
}
};
Expand Down

0 comments on commit 3bbc9ef

Please sign in to comment.