fix(docs-infra): improve skip-to-main-content method to focus <main> element instead of h1

Update the skip-to-main-content behavior to focus the <main> element when present, with a fallback to the first heading for legacy layouts without a main landmark.
This commit is contained in:
omar-almasry11 2026-01-14 20:48:30 -05:00 committed by Alon Mishne
parent 6dff1cf85d
commit 30b78bdc71

View file

@ -82,6 +82,14 @@ export class AppComponent {
}
protected focusFirstHeading(): void {
const main = this.document.querySelector<HTMLElement>('main');
if (main) {
main.setAttribute('tabindex', '-1');
main.focus();
return;
}
// Fallback: focus the first h1 (legacy support for pages without main)
const h1 = this.document.querySelector<HTMLHeadingElement>('h1:not(docs-top-level-banner h1)');
h1?.focus();
}