From 30b78bdc71d2d53d91d640130e5af42d2cfb9bcf Mon Sep 17 00:00:00 2001 From: omar-almasry11 Date: Wed, 14 Jan 2026 20:48:30 -0500 Subject: [PATCH] fix(docs-infra): improve skip-to-main-content method to focus
element instead of h1 Update the skip-to-main-content behavior to focus the
element when present, with a fallback to the first heading for legacy layouts without a main landmark. --- adev/src/app/app.component.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adev/src/app/app.component.ts b/adev/src/app/app.component.ts index d1a5618d66e..37dd27d79c4 100644 --- a/adev/src/app/app.component.ts +++ b/adev/src/app/app.component.ts @@ -82,6 +82,14 @@ export class AppComponent { } protected focusFirstHeading(): void { + const main = this.document.querySelector('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('h1:not(docs-top-level-banner h1)'); h1?.focus(); }