diff --git a/.changeset/hungry-cats-juggle.md b/.changeset/hungry-cats-juggle.md new file mode 100644 index 0000000000..af52f9388f --- /dev/null +++ b/.changeset/hungry-cats-juggle.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Fix an issue with index page of documentation site being re-rendered. diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx index 3656d22326..8d23ed7b8b 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPageContent/dom.tsx @@ -47,6 +47,7 @@ import { handleMetaRedirects, } from '../../transformers'; import { useNavigateUrl } from './useNavigateUrl'; +import { useParams } from 'react-router-dom'; const MOBILE_MEDIA_QUERY = 'screen and (max-width: 76.1875em)'; @@ -69,6 +70,7 @@ export const useTechDocsReaderDom = ( const scmIntegrationsApi = useApi(scmIntegrationsApiRef); const { state, path, content: rawPage } = useTechDocsReader(); + const { '*': currPath = '' } = useParams(); const [dom, setDom] = useState(null); const isStyleLoading = useShadowDomStylesLoading(dom); @@ -277,8 +279,8 @@ export const useTechDocsReaderDom = ( } // Skip this update if the location's path has changed but the state - // contains a page for another page that isn't loaded yet. - if (!window.location.pathname.endsWith(path)) { + // contains a page that isn't loaded yet. + if (currPath !== path) { return; } @@ -297,7 +299,7 @@ export const useTechDocsReaderDom = ( return () => { shouldReplaceContent = false; }; - }, [rawPage, path, preRender, postRender]); + }, [rawPage, currPath, path, preRender, postRender]); return dom; };