Skip to content

Commit

Permalink
fix: scroll to hash on resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Dec 12, 2023
1 parent 2045540 commit a98c823
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/react-router/src/RouterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ function Transitioner() {
pathChanged:
routerState.location!.href !== routerState.resolvedLocation?.href,
})

if (
routerState.location.hash !== routerState.resolvedLocation?.hash &&
(document as any).querySelector
) {
console.log('hello', routerState.location.hash)
const el = document.getElementById(
routerState.location.hash,
) as HTMLElement | null
if (el) {
el.scrollIntoView()
}
}
router.pendingMatches = []

router.__store.setState((s) => ({
Expand Down

0 comments on commit a98c823

Please sign in to comment.