diff --git a/.changeset/tender-pumpkins-burn.md b/.changeset/tender-pumpkins-burn.md new file mode 100644 index 0000000000..e431614707 --- /dev/null +++ b/.changeset/tender-pumpkins-burn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Fixed a bug where scrolling for anchors where the id starts with number didn't work for the current page. diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx index 98bd6d867c..0e811af6e0 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx @@ -184,7 +184,7 @@ export const useTechDocsReaderDom = ( navigate(`${parsedUrl.pathname}${parsedUrl.hash}`); // Scroll to hash if it's on the current page transformedElement - ?.querySelector(`#${parsedUrl.hash.slice(1)}`) + ?.querySelector(`[id="${parsedUrl.hash.slice(1)}"]`) ?.scrollIntoView(); } } else {