Tag-pill actions not working

Trying to implement behaviour similar to the default tag list to create one-to-many relationships in one of my plugins. It seems as though the actions of the tag-pill do not get triggered whereas those of the button do. What am I missing?

This dumbed down version was exported from tiddlywiki.com.

result: a
test: a b c d
title: TestTiddler

<<tag-picker
  tagListFilter:"[<currentTiddler>get[test]enlist-input[]] -[<currentTiddler>get[result]enlist-input[]]"
  tagField:"result"
>>

!! Klicking the pill does not work
<$list filter="[<currentTiddler>get[result]enlist-input[]]" variable="tagname">
  <$transclude
    $variable="tag-pill"
    tag=<<tagname>>
    actions="""<$action-listops $field="result" $subfilter="-[<tagname>]" />"""
  />
</$list>

!! Klicking the button work
<$vars tagname="a">
  <$button actions="""<$action-listops $field="result" $subfilter="-[<tagname>]" />"""
>
    Klick
  </$button>
</$vars>

Also any tips how to improve this use-case are very much appreciated.

Thank you for any help!

Unlike the $button widget, the $transclude widget does not have an actions=... parameter to process click events. To handle clicks within transcluded content, you can surround the $transclude widget with an $eventcatcher widget, like this:

<$eventcatcher $click="""<$action-listops $field="result" $subfilter="-[<tagname>]" />""">
  <$transclude $variable="tag-pill" tag=<<tagname>>/>
</$eventcatcher>

Note that if the transcluded content includes widgets that process clicks (e.g., $button widgets), then those widgets will handle the click events first and the surrounding $eventcatcher will never see those events.

-e

Thank you Eric, that did the trick!

Reading the documentation for the transclude widget I was under the assumption that the “actions” parameter (without a $ sign) would be passed down to the transcluded content. Since it works for the tag parameter, this - at least for me - is unexpected behaviour.

{attributes not starting with $} – Any other attributes that do not start with a dollar are used as parameters to the transclusion

It seems that the tag-pill macro’s handling for the actions=... parameter may be broken. I tried this simple test:

<<tag-pill tag:"a" actions:"""<$action-confirm $message="test"/>""">>

and while it does display the tag pill for tag “a”, it doesn’t perform the click action.

-e

It seems, there is a problem in the documentation. If the actions parameter is used, the element-tag needs to be a $button element. eg:

<<tag-pill tag:"a" element-tag:"$button" actions:"""<$action-confirm $message="test"/>""">>

Edit: I did create a PR: [Docs] Improve tag-pill documentation and examples by pmario · Pull Request #9580 · TiddlyWiki/TiddlyWiki5 · GitHub

2 Likes

Thank you Mario, that was crazy fast!