diff --git a/.changeset/fast-onions-thank.md b/.changeset/fast-onions-thank.md new file mode 100644 index 000000000..bab8fabb9 --- /dev/null +++ b/.changeset/fast-onions-thank.md @@ -0,0 +1,5 @@ +--- +'@myst-theme/site': patch +--- + +Simplifications to skip-handler. diff --git a/packages/site/src/components/SkipToArticle.tsx b/packages/site/src/components/SkipToArticle.tsx index c07bd081e..eb3294e36 100644 --- a/packages/site/src/components/SkipToArticle.tsx +++ b/packages/site/src/components/SkipToArticle.tsx @@ -1,14 +1,12 @@ import { useCallback } from 'react'; -function makeSkipClickHander(hash: string) { +function makeSkipClickHandler(hash: string) { return (e: React.UIEvent) => { e.preventDefault(); const el = document.querySelector(`#${hash}`); if (!el) return; - el.scrollIntoView({ behavior: 'smooth' }); + (el.nextSibling as HTMLElement).focus(); history.replaceState(undefined, '', `#${hash}`); - (el.nextSibling as HTMLElement).focus({ preventScroll: true }); - (e.target as HTMLElement).blur(); }; } @@ -22,8 +20,8 @@ export function SkipToArticle({ const fm = 'skip-to-frontmatter'; const art = 'skip-to-article'; - const frontmatterHander = useCallback(() => makeSkipClickHander(fm), [frontmatter]); - const articleHandler = useCallback(() => makeSkipClickHander(art), [article]); + const frontmatterHandler = useCallback(() => makeSkipClickHandler(fm), [frontmatter]); + const articleHandler = useCallback(() => makeSkipClickHandler(art), [article]); return (
Skip to article frontmatter