How can I unfold a Tiddler when I click on a link that goes to it?

When I click on a link that opens a Tiddler and this Tiddler is already opened and folded, the Tiddler will remain folded. I’d like to change this behavior to make clicking on Tiddler links also unfold the Tiddler… Something as the following:

My assumption is that I need to edit the wikitext of a core Tiddler… But I have no idea how to search for it. Is there any way of changing this behavior? So when I click to open a Tiddler that’s opened and folded it’ll unfold the Tiddler?

In the TW I use for taking notes, I modified the link clicking behavior. In my case I wanted the clicked tiddler to always be at the top of the story river. IOW, if the tiddler is already open and a link to that tiddler is clicked, then it should move to the top.

The core tiddler you are looking for is $:/core/ui/PageTemplate. However, modfying the core tiddler is not the only option and not the one I chose. A recent version of Tiddlywiki introduced the ability to create alternate page layouts.

So I created a copy of the $:/core/ui/PageTemplate tiddler and made my link changes therein. Then I added the $:/tags/Layout tag and use ctrl-shift-L to switch to this layout. Be sure to also change the description field in your copy so you can distinguish between your and the original layout in the layout selector.

My change involved adding a link catcher widget and that should also work for you.

Below are the changes I made. Instead of using action-listops like I did, you might be able to use action-deletetiddler with $filter = [title<navigateTo>addprefix[$:/state/folded/]]

@@ -22,13 +22,17 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
 <$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
 
 <$dropzone enable=<<tv-enable-drag-and-drop>>>
-
+<$linkcatcher message="tm-navigate" actions="""
+<$action-listops $tiddler="$:/StoryList" $subfilter="[<navigateTo>] +[putfirst[]limit[15]]"/>
+""">
 <$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem">
 
 <$transclude tiddler=<<listItem>>/>
 
 </$list>
 
+</$linkcatcher>
+
 </$dropzone>
 
 </$navigator>
@@ -36,3 +40,4 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
 </div>
 
 </$vars>

I’m not sure if there is a better way, but this approach works for me.

2 Likes

Eg: If the HelloThere tiddler is folded, there is a state tiddler named: $:/state/folded/HelloThere.
If you delete this tiddler, the folded state from HelloThere will be gone.

IMO the easiest way is to change the TW link behaviour. Everytime a link is clicked, the corresponding folding state should be deleted.

You can easily test it …

I’m not sure yet, how I personally would implement it. … still thinking :wink:

Do you want to disable the folded state only from links in the sidebar or should it be also from links in the story-river?

That’s how I would do it. This will work globally. … I think.

Have a closer look at those doc tiddlers.

remove-folded-on-link-click-$ _core_ui_PageTemplate.json (1.6 KB)

have fun!
mario

3 Likes

@pmario Thanks!

For me, it’s working globally on all cases that I’ve tested and that I wanted it to work. :slight_smile:

I like this global solution!

A check box to enable it would be useful, and yes worthy of the core. Folding tiddlers is to put them out of the way, whist keeping their title in the story. The idea that opening/navigating to them we are keen to see their content not the hidden state makes sense.

Additional Information.
Remember;

It all depends on what links you are using to open said tiddlers. Often rather than the sideBar and story river, we often generate lists of links in tiddlers. Keep in mind if you have a bespoke list you can always apply custom behaviours to those links. Look at the $list widget and you will see the additional parameters replating to navigation.

If you construct a list of links using buttons (eg with the class tc-btn-invisible tc-tiddlylink) you can use the actions in the button to trigger the unfolding.

It surprises me actually the a the list and link widgets do not have an actions parameter for the links within them.

7 posts were split to a new topic: Executing actions on navigation clicks