-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
TOC navigations should be recorded in history #1248
Comments
I'd like to work on this issue. My approach would be to use history.pushState() instead of just scrolling, allowing in-page navigation to be recorded in history and listen for popstate events to restore correct TOC position when using back/forward navigation. Any feedback or suggestions? |
@Jinash-Rouniyar Thank you for your comment. Your appraoch sounds worth a try at least. @ShaopengLin Any feedback? |
@Jinash-Rouniyar Thats sounds good, though I have a concern: One obvious caveat you need to be aware of is that users can switch websites, which reloads the webpage. History inside Javascript might not be persistent. If it is indeed not persistent, I would recommend using the Qt WebEngine history, as all user actions stems from the Qt side. You can do special handling for TOC navigations and signal to Javascript page the scroll location. In addition, less race condition to worry about :) |
@kelson42 I've implemented the Qt WebEngine history approach as suggested by @ShaopengLin, and the in-page navigation works smoothly even when the users switch sites, however, there are two issues I need to address 1) When a TOC item is clicked, the code pushes a state that differs only by the hash(anchor), so this change isn't considered full navigation by the browser, and I need to use alt + right/left to activate back/forward navigation on the page. 2) The TOC UI does not update on back/forward navigation. Any suggestions? |
@Jinash-Rouniyar Nice, create a PR, put it in draft and fix the two problem left. |
|
@kelson42 I've resolved the TOC UI update and shared a video for @ShaopengLin to review the other issue I have been facing. https://www.loom.com/share/0827d2d2abbc4f6c9c4cc6a9978c3b44?sid=018da29b-fb5c-4aa4-89cc-5a9738a0b77d |
Currently, the TOC #42 navigations do not go through the Qt system and use Javascript to scroll directly. It would be great to have an in-page history, where the history records those actions but sends them to Javascript for scrolling instead of refreshing the current page to the URL.
Note that if a page is refreshed, all DOM states are also reset, which is not what we want. This is the reason why we cannot use setUr to navigate to TOC entries.
The text was updated successfully, but these errors were encountered: