-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use browser history when updateHistory="yes" and updateAddressBar="no"
#9608
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
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Confirmed: yaisog has already signed the Contributor License Agreement (see contributing.md) |
📊 Build Size Comparison:
|
| Branch | Size |
|---|---|
| Base (master) | 2450.9 KB |
| PR | 2456.8 KB |
Diff: ⬆️ Increase: +5.9 KB
✅ Change Note Status
All change notes are properly formatted and validated!
📝 $:/changenotes/5.4.0/#9608
Type: enhancement | Category: internal
Release: 5.4.0
Enable browser navigation without changing location hash
🔗 #9608
👥 Contributors: yaisog
📖 Change Note Guidelines
Change notes help track and communicate changes effectively. See the full documentation for details.
| @@ -0,0 +1,3 @@ | |||
| title: $:/config/Navigation/UpdateAddressBar | |||
|
|
|||
| no | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume, these 2 settings are only set for testing. right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. Otherwise, you'd have to set this manually each time you load the wiki.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need new setting options in the ControlPanel - Settings tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think we don't. This PR just combines the UpdateAddressBar option "Do not update the address bar" with the UpdateHistory option "Update history". This combination had no effect until this PR, but describes accurately what is happening here.
|
I added a history backstop, which is a tiddler that is shown before another click on "Back" would leave the wiki. This is more specific than a general warning when leaving the wiki by any means. |
|
Could this whole mechanism be implemented as a plugin? At the very least, that would allow it to be available much sooner, and would also help to demonstrate its general stability and gauge its appeal/usefulness to the TW community at large. I also wonder if the "backstop" feature could be implemented as a separate (and much simpler) "always ask before exiting" feature, independent of the "use browser history to navigate" functionality. Ideally, I'd also like the "HistoryBackstopTiddler" to be able to optionally just invoke action widgets instead of being displayed in the StoryRiver. This could then be used somewhat like the "ConfirmBeforeExit" plugin I wrote for TWClassic (which also closed active tiddler editors and then prompted to save before continuing to exit. |
|
Hi @ericshulman, the startup part (preparing the history and attaching the eventListener) could easily be externalized into a plugin, but updating the history on each navigation event alters the updateLocationHash() method of startup/story.js. One could put this in a plugin, but then that plugin must be updated (by the maintainer and the user) to benefit from core updates. I could, probably, instead of attaching to the existing change event listener, create an extra listener that does the history updating. This would be plugin-compatible. I like your action widget idea. I think it would make sense to use a tag-based approach and execute all actions in tiddlers with something like
When I took this functionality out of this PR, I actually put it into a plugin: |
I feel that "HistoryBackstopActions" is too technical. How about calling it This could be used so that whenever you try to leave the TiddlyWiki, it could reset various As you've noted, 'onbeforeunload' is specifically limited to returning ONLY a confirmation message, so the above handling would somehow have to be triggered separately, if that is possible. |
|
I've checked again and I don't think there is a Regarding the history backstop, when this is shown, the user likely doesn't want to navigate away from the wiki. Thus, resetting state tiddlers and saving might be premature. An alternative to the backstop tiddler that could be invoked would be a notification or a warning modal (which could have an exit option via history.back(), which cannot be triggered via action widgets, though). The usefulness of the exit actions is unfortunately pretty much limited to browser back / forward navigation and preventing accidental wiki exits... |
…t of updateLocationHash
|
Hi @ericshulman, concerning the plugin: I made a "prerelease plugin" that takes the exact code of this PR and makes it into a plugin. This way, the chance for a serious conflict if someone with the plugin upgrades to 5.4.0 would be minimized, because the plugin wouldn't change the core code. |
|
Hi @ericshulman, as you might have seen on Talk TW, I made a true plugin with this functionality that should integrate in any wiki without needing to replace story.js. This will probably make it more difficult to roll out the same functionality as a core feature at some point in the future, but it is available much sooner. |
Until now navigation via the Back and Forward buttons is only enabled when
$:/config/Navigation/UpdateAddressBaris set topermalinkorpermaviewif$:/config/Navigation/UpdateHistoryis also set toyes. This PR would also enable the use of these buttons whenUpdateAddressBarisno. Instead of changing the locationHash, the navigated tiddler is added to the browser history state object. Apopstatehandler is added to the window object that evaluates the state object and if it exists then navigates to the tiddler described therein.The implementation includes a backstop feature that defines a boundary tiddler at the beginning of the browser history stack. The tiddler that is shown as a backstop can also be configured via
$:/config/Navigation/HistoryBackstopTiddler. It prevents users from navigating beyond their TiddlyWiki session when using the browser's back button. Before leaving the wiki, they'll reach the configured backstop tiddler showing a corresponding warning.Resolves #9604
PS: In the preview,
$:/config/Navigation/UpdateHistoryis set to yes by default to make testing the feature easier.