How can I use "tm-navigate" to create an action to go back to the last tiddler?

I would like to create an action that would allow me to push a button and go back to the last tiddler.

<$button>
<$action-navigate $to="????"/>
❮❮
</$button>

TiddlyWiki by default does not have a concept of a “last” tiddler as there are many ways to navigate to another tiddler, including by simply scrolling. If you describe your use case in more detail, a suitable solution might be found.

It’s really because I am using your single page mode and when I go to open a new tiddler it doesn’t navigate to it.

So adding a line of code in $:/core/ui/Actions/new-tiddler:

\define get-tags() $(textFieldTags)$ $(tagsFieldTags)$
<$vars textFieldTags={{$:/config/NewTiddler/Tags}} tagsFieldTags={{$:/config/NewTiddler/Tags!!tags}}>
<$action-sendmessage $message="tm-new-tiddler" tags=<<get-tags>>/>
+<$action-navigate $to="Draft of 'New Tiddler'"/>
</$vars>

Navigating to Draft of 'New Tiddler' works just fine. I checked $:/HistoryList and it’s in there. In theory, this could work. But, I bet you probably have a better solution.

Do you mean this file? TiddlyWiki — a non-linear personal web notebook

If so, can you provide step by step instructions to replicate the problem where the new tiddler is not being navigated to?

That’s exactly the file I am talking about.

I imported these tiddlers onto my wiki:

  • $:/sq/ui/SingleTiddler/PageTemplate
  • $:/sq/ui/SingleTiddler/PageTemplate/story
  • $:/core/ui/SideBar/Open

Then I go to $:/ControlPanel > Appearance > Layout and select Single Tiddler.

The tiddlers behave like I want them to. But when I try to create a new tiddler it does not navigate to it, but it appears in the History tab.

Try setting $:/config/Navigation/openLinkFromOutsideRiver to bottom.

Thank you so much, this did the trick!

Another approach is to get the last tiddler (Last but one, or penultimate tiddler) from the history mechanism;

First here is a simple history sidebar tab I made earlier;

history-sidebar.json (536 Bytes)

Then I noticed if in draft mode the draft is the current and the original is the second, so I have excluded !has[draft.of] so it will ignore drafts. I then added this to the tiddler $:/PSaT/history-sidebar

Last but one
<$list filter="[{$:/HistoryList}split<title-string>splitbefore<end-title>removesuffix<end-title>reverse[]is[tiddler]!has[draft.of]nth[2]]">

</$list>

So the result is the link to the last tiddler you can place this inside a button to go back (below). In this model you can toggle between two tiddlers as focusing on one makes the other the previous.

I think we need to check if this causes problems with the draft mechanism.

Here is the button version

<$list filter="[{$:/HistoryList}split<title-string>splitbefore<end-title>removesuffix<end-title>reverse[]is[tiddler]!has[draft.of]nth[2]]">
   <$button to=<<currentTiddler>> >Last</$button>
</$list>

Yes, I need to allow navigation to the draft of, l but not to the pre-draft title when clicking last.