Skip to content
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
1 change: 1 addition & 0 deletions packages/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export default class Router implements BaseRouter {
// If the url change is only related to a hash change
// We should not proceed. We should only change the state.
if (this.onlyAHashChange(as)) {
this.asPath = as
Router.events.emit('hashChangeStart', as)
this.changeState(method, url, as)
this.scrollToHash(as)
Expand Down
12 changes: 12 additions & 0 deletions test/integration/client-navigation/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ describe('Client Navigation', () => {

await browser.close()
})

it('should not run getInitialProps when removing via back', async () => {
const browser = await webdriver(context.appPort, '/nav/hash-changes')

const counter = await browser
.elementByCss('#scroll-to-item-400').click()
.back()
.elementByCss('p').text()

expect(counter).toBe('COUNT: 0')
await browser.close()
})
})

describe('when hash set to empty', () => {
Expand Down