Skip to content

Commit 7d75265

Browse files
author
Peter Bengtsson
authored
hydration fails on CollapsibleSection with hash in URL (#24105)
1 parent ef58537 commit 7d75265

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

components/page-header/Breadcrumbs.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ export type BreadcrumbT = {
1212

1313
export const Breadcrumbs = () => {
1414
const router = useRouter()
15-
const pathWithLocale = `/${router.locale}${router.asPath.split('?')[0]}` // remove query string
15+
// remove query string and hash
16+
const pathWithLocale = `/${router.locale}${router.asPath.split('?')[0].split('#')[0]}`
1617
const { breadcrumbs } = useMainContext()
1718

1819
return (
1920
/*
20-
NOTE: The breadcrumbs class and the nav tag are used by the
21-
LUNR search scripts. The a tag generated by the Link is also used.
21+
NOTE: The breadcrumbs class and the nav tag are used by the
22+
Lunr search scripts. The a tag generated by the Link is also used.
2223
If these change, please also change
2324
updating script/search/parse-page-sections-into-records.js.
2425
*/

components/sidebar/SidebarProduct.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export const SidebarProduct = () => {
3030
}
3131

3232
const productTitle = currentProductTree.renderedShortTitle || currentProductTree.renderedFullTitle
33-
const routePath = `/${router.locale}${router.asPath.split('?')[0]}` // remove query string
33+
// remove query string and hash
34+
const routePath = `/${router.locale}${router.asPath.split('?')[0].split('#')[0]}`
35+
3436
const hasExactCategory = !!currentProductTree.childPages.find(({ href }) =>
3537
routePath.includes(href)
3638
)

0 commit comments

Comments
 (0)