How to get the dropdown working correctly for tag pills that are transcluded multiple times within a tiddler?

When you use the tag macro to generate the same tag multiple times within a tiddler, clicking on a tag causes the dropdown to appear for every instance of the tag, not just the one that you clicked on.

Are there any tricks to prevent this behaviour, so that the dropdown appears only for the particular tag pill that you clicked on?

Here is an example of a task list that demonstrates the problem. Click on one of the tags in the task list and you will see that multiple dropdowns appear.

I had the same problem, please refer to this topic for the solution:

Use variable=“transclusion” in a list widget to get unique popups - Tips & Tricks - Talk TW (tiddlywiki.org)

Solution: add counter="transclusion" to the list widget that generates multiple identical tag pills. In this case it would be the one inside the table, so it should be <$list filter="[tag[To do]]" counter="transclusion">. Fixed example.

2 Likes

Since it is a recurring question, maybe it should be clarified in the official documentation? I’ll try to document it myself when I find some time. Any ideas on how to take on it from more experienced users are welcome.

I understand the issue is not with the tag macro specifically, but any similar interactive macros/transclusions inside a list widget. But since the tag macro is the only one ever asked about in this context, I’m thinking maybe there could be a link to an explanation from the tag macro and from the list widget tiddlers in docs.

Saq has just released a new version of the TW PR Maker Edition, which will let you create a pull-request directly from within that wiki.
Before you send the PR-request you should backup your tiddlers with the Export Button visible top right of the tiddler list

2 Likes

I have created this docs PR: Add docs on achieving unique `tag` macro dropdowns inside `list` widget by mateuszwilczek · Pull Request #7639 · Jermolene/TiddlyWiki5 · GitHub

The PR Maker works great btw!

2 Likes

Thanks for doing that work @vilc and @pmario

I had a brief look in the core to see how and why this works, but the transclusion variable is not used in the macro definition. I have an idea why it works, but want to identify exactly why, to see if it is a robust method and will not impact something else. Such as additions to the tag pill dropdown and other uses of tags.

@TW_Tones I think this is the explanation of why and how:

My simplified understanding of it is that it has nothing to do with the tag macro specifically. Another macro (qualify) “decides” where to draw the dropdown. If all the tag macro calls are identical, the dropdowns will be displayed all over them. Having the transclusion variable differ for each pass of list makes each tag macro call unique. The same problem and solution should apply to anything depending on the qualify macro, but I don’t know what that would be other than the tag macro.

Yes @vilc I have a similar understanding, as the author of “reimagine tags” I have a bundle of utilities that use the $:/tags/TagDropdown tag, I wanted to understand, even see the code, to be sure there are no unwanted results.

  • I also made use of the transclude variable in a number of tricks, although one was to do what the <<thisTiddler>> variable now does.