From f0fb9153b7e30ce87d1492ddb9201f27359d94ea Mon Sep 17 00:00:00 2001 From: Nicolas Arnold Date: Mon, 21 Mar 2022 17:35:53 +0000 Subject: [PATCH] Fix broken querySelectors on techdocs This change fixes the broken pattern for selecting DOM elements to scroll to. Previously it had error messages like so: ``` Uncaught DOMException: Failed to execute 'querySelector' on 'Element': '#fn:someidtag' is not a valid selector. ``` This did not bode well with the techdocs integration with footnotes. The query has now changed to include something that is expected by the DOM queries. Signed-off-by: Nicolas Arnold --- .changeset/silver-panthers-occur.md | 5 +++++ plugins/techdocs/src/reader/components/Reader.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/silver-panthers-occur.md diff --git a/.changeset/silver-panthers-occur.md b/.changeset/silver-panthers-occur.md new file mode 100644 index 0000000000..211e760d09 --- /dev/null +++ b/.changeset/silver-panthers-occur.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Fix broken query selectors on techdocs diff --git a/plugins/techdocs/src/reader/components/Reader.tsx b/plugins/techdocs/src/reader/components/Reader.tsx index 9ce9ad5d6d..dc59070f1c 100644 --- a/plugins/techdocs/src/reader/components/Reader.tsx +++ b/plugins/techdocs/src/reader/components/Reader.tsx @@ -803,7 +803,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 {