Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add scroll restoration handling after render is done" #14075

Merged
merged 2 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ type ComponentLoadCancel = (() => void) | null

type HistoryMethod = 'replaceState' | 'pushState'

const manualScrollRestoration =
typeof window !== 'undefined' && 'scrollRestoration' in window.history

function fetchNextData(
pathname: string,
query: ParsedUrlQuery | null,
Expand Down Expand Up @@ -259,12 +256,6 @@ export default class Router implements BaseRouter {
}

window.addEventListener('popstate', this.onPopState)

// enable custom scroll restoration handling when available
// otherwise fallback to browser's default handling
if (manualScrollRestoration) {
window.history.scrollRestoration = 'manual'
}
}
}

Expand Down Expand Up @@ -502,21 +493,6 @@ export default class Router implements BaseRouter {
}

Router.events.emit('beforeHistoryChange', as)

if (manualScrollRestoration && history.state) {
const {
url: curUrl,
as: curAs,
options: curOptions,
} = history.state

this.changeState('replaceState', curUrl, curAs, {
...curOptions,
_N_X: window.scrollX,
_N_Y: window.scrollY,
})
}

this.changeState(method, url, as, options)

if (process.env.NODE_ENV !== 'production') {
Expand All @@ -534,10 +510,6 @@ export default class Router implements BaseRouter {
}

Router.events.emit('routeChangeComplete', as)

if (manualScrollRestoration && '_N_X' in options) {
window.scrollTo(options._N_X, options._N_Y)
}
return resolve(true)
}
)
Expand Down
1 change: 0 additions & 1 deletion test/integration/scroll-restoration/pages/another.js

This file was deleted.

50 changes: 0 additions & 50 deletions test/integration/scroll-restoration/pages/index.js

This file was deleted.

106 changes: 0 additions & 106 deletions test/integration/scroll-restoration/test/index.test.js

This file was deleted.