Skip to content

Conversation

@yaisog
Copy link
Contributor

@yaisog yaisog commented Jan 13, 2026

This is a proof-of-concept related to the discussion in #9572

The $action-navigate widget now has an $actions parameter 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-scroll or tm-focus-selector messages 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.

@netlify
Copy link

netlify bot commented Jan 13, 2026

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit 1ebcd4d
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/69669be24286f2000829f282
😎 Deploy Preview https://deploy-preview-9578--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

Confirmed: yaisog has already signed the Contributor License Agreement (see contributing.md)

@github-actions
Copy link

github-actions bot commented Jan 13, 2026

📊 Build Size Comparison: empty.html

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.

@yaisog
Copy link
Contributor Author

yaisog commented Jan 13, 2026

When #9528 is merged, this functionality should also work for $action-sendmessage with $message="tm-navigate" by passing an actions parameter with the message.

@saqimtiaz
Copy link
Member

How would we address the following use case:

  • a custom layout with no storyriver
  • clicking a button changes a state tiddler and this creates a new DOM element that should be focused after creation.

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.

@yaisog
Copy link
Contributor Author

yaisog commented Jan 16, 2026

  • clicking a button changes a state tiddler and this creates a new DOM element that should be focused after creation

You could work around that with <$action-navigate $tiddler=<<currentTiddler>> $scroll=no $actions="<<actions>>" /> which will basically do nothing but execute the delayed actions.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants