Skip to content

Commit

Permalink
Force reflow when setting scrollBehavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jankaifer committed Dec 6, 2022
1 parent efe1742 commit 6ba1f64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/next/client/index.tsx
Expand Up @@ -697,6 +697,7 @@ function doRender(input: RenderRouteInfo): Promise<any> {
const htmlElement = document.documentElement
const existing = htmlElement.style.scrollBehavior
htmlElement.style.scrollBehavior = 'auto'
htmlElement.getClientRects()
window.scrollTo(input.scroll.x, input.scroll.y)
htmlElement.style.scrollBehavior = existing
}
Expand Down
1 change: 1 addition & 0 deletions packages/next/shared/lib/router/router.ts
Expand Up @@ -659,6 +659,7 @@ function handleSmoothScroll(fn: () => void) {
const htmlElement = document.documentElement
const existing = htmlElement.style.scrollBehavior
htmlElement.style.scrollBehavior = 'auto'
htmlElement.getClientRects()
fn()
htmlElement.style.scrollBehavior = existing
}
Expand Down

0 comments on commit 6ba1f64

Please sign in to comment.