Select Widget display issues

92 views
Skip to first unread message

scourfie...@gmail.com

unread,
Dec 27, 2020, 12:10:26 PM12/27/20
to TiddlyWiki
Hello all

I've got a select widget set up in the body of a tiddler to choose that tiddler's tag from a list of other tiddlers, in order to facilitate easy moving around within a table of contents. The widget is set up as follows:

<$select field='tags'><$list filter='[_object_type[location]!title<currentTiddler>!tag<currentTiddler>]'><option value=<<linkup>>><$view field='title'/></option></$list></$select>

_object_type is a custom field I've set up, and "location" is one of its possible values. <<linkup>> is seperately defined as:

\define linkup() [[$(currentTiddler)$]]

The linkup macro is used to make sure the tags are applied correctly for tiddlers in the list with spaces in their names. 

The strange issue I'm having however, is that once I choose an option in the dropdown box, it only remains displayed visually in the box  if the name contains spaces. If it does not, then the dropdown box appears to be empty (though the tag is still applied correctly). 

This is mostly a cosmetic issue, but one I'm curious about and would love to know if anyone understands this behaviour, as ideally I'd like the box to continue to display whatever has been selected.

Many thanks in advance if anyone knows what's going on here.

Joseph

Mark S.

unread,
Dec 27, 2020, 2:28:47 PM12/27/20
to TiddlyWiki
The reason it doesn't work is because when you put [[MySingleWordTag]] in tags, TW strips off the [[ and ]], so your text no longer matches.

The following worked in my tests. It uses the filter run evaluation to determine if braces need to be added, only adding them if there is more than one word.

<$vars myfilter="[split[ ]count[]compare:integer:eq[1]]" lf="[[" rt="]]" >

<$select field='tags'>
<$list filter='[_object_type[location]!title<currentTiddler>!tag<currentTiddler>]'>
<option value={{{ [<currentTiddler>filter<myfilter>] [<currentTiddler>addprefix<lf>addsuffix<rt>]+[first[]] }}}><$view field='title'/></option>
</$list></$select>

</$vars>
Message has been deleted

scourfie...@gmail.com

unread,
Dec 27, 2020, 4:10:55 PM12/27/20
to TiddlyWiki

Thanks Mark

I've had a go using your code, but I'm still getting the same behaviour. Any ideas?

Joseph


Mark S.

unread,
Dec 27, 2020, 4:47:58 PM12/27/20
to TiddlyWiki
It's hard to diagnose at a distance. But as you can see in the screenshot, it's working on mine. Possibly something got mangled when you copied the code?

You could download your tiddler set in a JSON bundle, and then post them here.



Mark S.

unread,
Dec 27, 2020, 4:51:47 PM12/27/20
to TiddlyWiki
In case things got mangled in copy/paste, I've attached a JSON file with the code that you can import.
SpecialSelect.json

Mark S.

unread,
Dec 27, 2020, 5:13:04 PM12/27/20
to TiddlyWiki
And here's a second version, that uses the action attribute. This is probably closer to the "official" way things should be done, and is easier to read.
SelectAndTagV2.json

scourfie...@gmail.com

unread,
Dec 28, 2020, 5:53:15 AM12/28/20
to TiddlyWiki
Thanks Mark. No idea why that first one didn't work but the second one works perfectly. I actually modified it slightly as follows, since I'm using this tiddler as a mask for several others so wanted them to be able to display different values.

\define tag-select-actions()
<$vars lf="[[" rt="]]" >
<$action-listops $tiddler=<<currentTiddler>> $field="tags" $filter={{{ [{!!_tag_selection}addprefix<lf>addsuffix<rt>]}}} />
</$vars>
\end

<$select field=_tag_selection actions=<<tag-select-actions>> >
<$list filter='[_object_type[location]!title<currentTiddler>!tag<currentTiddler>]'>
<option value=<<currentTiddler>> ><$view field='title'/></option>
</$list>
</$select>

Thanks again for your help
Reply all
Reply to author
Forward
0 new messages