fix(techdocs): Update keyboard focus on when clicking hash links

Signed-off-by: logonoff <git@logonoff.co>
This commit is contained in:
logonoff
2025-04-29 14:15:16 -04:00
parent 64ddf3097d
commit 7d445da49a
2 changed files with 12 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-techdocs': patch
---
Update keyboard focus on when clicking hash links. This fixes the issue where the "skip to content" link rendered by Material MkDocs isn't focused when used.
@@ -229,6 +229,13 @@ export const useTechDocsReaderDom = (
transformedElement
?.querySelector(`[id="${parsedUrl.hash.slice(1)}"]`)
?.scrollIntoView();
// Focus first focusable element in the target section
(
transformedElement
?.querySelector(`[id="${parsedUrl.hash.slice(1)}"]`)
?.querySelector('a, button, [tabindex]') as HTMLElement
)?.focus();
}
} else {
if (modifierActive) {