Sapper: Sub-pages like [id]/foo.html cannot navigate back to [id].html

Created on 11 Dec 2018  路  4Comments  路  Source: sveltejs/sapper

If you have a page structure like:

/accounts/[accountId].html
/accounts/[accountId]/foo.html

Then if you navigate from the first to the second, then press the back button in the browser, Sapper will not actually render the first page. It will just stay stuck on the second page.

I wrote a minimal repro using sapper-template. Steps to repro:

git clone https://github.com/nolanlawson/sapper-template.git \
  --branch demo-sapper-sub-page-bug \
  --depth 1 \
  --single-branch
cd sapper-template
npm i
npm run dev

Then in a browser, open localhost:3000, click on "Account # 1", then click on "my sub-page", then click the back button.

Expected result: it navigates back.

Actual result: the URL changes, but it does not navigate back.

bug

Most helpful comment

This is fixed in 0.25 thanks to @cudr

All 4 comments

It seems you can fix this by using [accountId]/index.html instead of [accountId].html, but it's a bit counter-intuitive that they would work differently.

The branch is using Sapper 0.22.10, but this looks to also be present in the latest 0.24.1.

It also looks like this is not specific to navigating back - if you click the 'Account # 1' in the header, while on the subpage, the same thing happens - the URL updates, the page does not.

Have same problem on Edge browser in production mode

This is fixed in 0.25 thanks to @cudr

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Snugug picture Snugug  路  4Comments

Rich-Harris picture Rich-Harris  路  3Comments

Rich-Harris picture Rich-Harris  路  4Comments

benmccann picture benmccann  路  3Comments

Rich-Harris picture Rich-Harris  路  3Comments