Skip to content

Commit

Permalink
hydration fails on CollapsibleSection with hash in URL (github#24105)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Jan 7, 2022
1 parent ef58537 commit 7d75265
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions components/page-header/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export type BreadcrumbT = {

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

return (
/*
NOTE: The breadcrumbs class and the nav tag are used by the
LUNR search scripts. The a tag generated by the Link is also used.
NOTE: The breadcrumbs class and the nav tag are used by the
Lunr search scripts. The a tag generated by the Link is also used.
If these change, please also change
updating script/search/parse-page-sections-into-records.js.
*/
Expand Down
4 changes: 3 additions & 1 deletion components/sidebar/SidebarProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const SidebarProduct = () => {
}

const productTitle = currentProductTree.renderedShortTitle || currentProductTree.renderedFullTitle
const routePath = `/${router.locale}${router.asPath.split('?')[0]}` // remove query string
// remove query string and hash
const routePath = `/${router.locale}${router.asPath.split('?')[0].split('#')[0]}`

const hasExactCategory = !!currentProductTree.childPages.find(({ href }) =>
routePath.includes(href)
)
Expand Down

0 comments on commit 7d75265

Please sign in to comment.