-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow actions to be executed after navigation DOM update #9578
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) | 2449.5 KB |
| PR | 2451.1 KB |
Diff: ⬆️ Increase: +1.5 KB
✅ Change Note Status
All change notes are properly formatted and validated!
📝 $:/changenotes/5.4.0/#9578
Type: feature | Category: widget
Release: 5.4.0
Add post-navigate actions support to tm-navigate message
🔗 #9578
👥 Contributors: yaisog
📖 Change Note Guidelines
Change notes help track and communicate changes effectively. See the full documentation for details.
|
When #9528 is merged, this functionality should also work for |
|
How would we address the following use case:
We also need to make sure that this works for content opened in new windows, that is a button in a new window triggers some actions that changes the DOM and after that we want to focus one of them. Overall using navigation and timeout feels very clunky and potentially error-prone, though I will admit that I cannot offer a better alternative at present. I am going to be away for a few days, I will give it some thought during that time. |
You could work around that with Your other usecases cannot be covered by this, I think. This is tied to navigation of some sort and needs a NavigatorWidget that processes the message originating within it. Otherwise you'd maybe need a new message type that gets processed near the rootWidget and does the same thing. But that would make it clunkier in usage for maybe 95% of the usecases where no external windows are involved. I'm curious what alternative you can come up with. |
This is a proof-of-concept related to the discussion in #9572
The $action-navigate widget now has an
$actionsparameter that takes an action string. This action string is executed after refresh has finished plus the time defined in $:/config/AnimationDuration, to allow for any animations to finish first.Primary usage would probably be to dispatch
tm-scrollortm-focus-selectormessages to scroll to / focus UI elements that only appear in the process of navigation (by e.g. opening new tiddlers). In WikiText, sending these messages directly after calling $action-navigate would not work, since all actions are queued before a refresh and the UI elements may not exist when targeted.Until now, the only solution was the $action-timeout widget by @ericshulman together with an estimate of the refresh duration. If the estimate was too short, the actions fail; if too long, unnecessary time is wasted.
I've put this into the NavigatorWidget, since this is probably the most common usecase. For actions-after-refresh in any situation without navigating to another tiddler, one could navigate to the currentTiddler
$scroll=no, passing the $actions to the $action-navigator widget. These would then be executed at the end of the refresh cycle without any preceding UI change.I've created a test tiddler with a button that navigates to another tiddler and then scrolls back to the top.