Browser button "Return to previous page" incorrect scrolling behaviour
nomisbo opened this issue · comments
Summary
When using links to other references within one book the "Return to previous page" button of browsers does not lead back to the previous postition in the document. Instead the scroll position is determined by the URL. This deviates from expected standard behaviour of websites.
- HonKit version: 4.0.7
Step to reproduce
- Go to https://honkit.netlify.app/pages.html
- Scroll to Button
- click on "templating" link
- click Back Button of browser
Expected results
Page shows previous scroll position (Button of Page)
Actual results
Page is not scrolled to button but shows to the beginning of the page
HonKit default theme use pjax-like navigation.
Probably, we need to store scroll position before going to next page.
- store scroll position for the page to sessionStorage
- navigation
- back navigation to the page
- restore scroll position from sessionStorage if scroll position is saved
Curretly, It looks like scroll to .book-summary
when changing page.
honkit/packages/@honkit/theme-default/src/js/theme/navigation.js
Lines 320 to 337 in b723ce5
📝 New Navigation API relates with this issue, but it is in only Chrome.