Skip to content

Commit

Permalink
Fix #top anchor link scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
lebreRafael committed Aug 27, 2020
1 parent 990c179 commit 7fd0807
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,9 @@ export default class Router implements BaseRouter {

scrollToHash(as: string): void {
const [, hash] = as.split('#')
// Scroll to top if the hash is just `#` with no value
if (hash === '') {
// Scroll to top if the hash is just `#` with no value or `#top`
// To mirror browsers
if (hash === '' || hash === 'top') {
window.scrollTo(0, 0)
return
}
Expand Down

0 comments on commit 7fd0807

Please sign in to comment.