Fix scrolling for anchors on the current page

Signed-off-by: drankou <aliaksandr.drankou@productboard.com>
This commit is contained in:
drankou
2022-09-05 10:56:27 +02:00
parent 973b1b2277
commit e97d616f08
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -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.
@@ -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 {