TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.97k stars 1.18k forks source link

[IDEA] Store Tags as Displayed #8228

Open kookma opened 3 months ago

kookma commented 3 months ago

Is your feature request related to a problem? Please describe. TiddlyWiki shows the tags on Tiddler by sorting versus title, but it stores them in the order they added. This cause confusion and incompatibly in some operations.

Describe the solution you'd like Please store tags sorted by title, when adding tag to tags field, or show tags on the tiddler as they appear in the tags field

Additional context I think it is simple to sort the tags field when a new tag is added!

pmario commented 3 months ago

In no way should the sort order of tags cause incompatibility. If that is a problem the code which is incompatible needs to be adjusted.


In the tiddler tags-field, I personally would like to have tags stored in order of "importance". Importance depends on the users point of view and it may be different for every user.

Tag-lists created with list-widgets are also sorted in the order the list-field defines it. If there is a list field, the order may be confusing

twMat commented 3 months ago

The current enforced sorting, which takes away control from the user, is unfortunate. IMO, the "natural default" should be that tags appear in the order that the user enters them. But it should be simple to, in edit-mode, rearrange them, ideally via drag'n drop.

kookma commented 3 months ago

In no way should the sort order of tags cause incompatibility. If that is a problem the code which is incompatible needs to be adjusted.

Would you please tell me what is the benefit of storing tags in different order than displayed? Right now if I add thisTag first and myTag last (based on my preferences or importance) TW shows tags in this order "myTag", "thisTag"?! Why, because the ui template in TiddlyWiki read tags field and sort them by name! and this quite confusing!

I agree to keep the order of tag in tags field in the same way user added tags (e.g. by preference or importance) BUT TiddlyWiki should display them in the same order not sort them!

See: https://github.com/Jermolene/TiddlyWiki5/blob/master/core/ui/ViewTemplate/tags.tid#L6

<div class="tc-tags-wrapper"><$list filter="[all[current]tags[]sort[title]]" template="$:/core/ui/TagTemplate" storyview="pop"/></div>

Look at the sort in [all[current]tags[]sort[title]]!

pmario commented 3 months ago

Look at the sort in [all[current]tags[]sort[title]]!

Yes that's because Jeremy likes it that way. But the template is simple enough that you can change it.

Jermolene commented 3 months ago

Hi @kookma the ordering of tag pills by recency is undoubtedly potentially confusing but equally it is not surprising that some users have come to expect and rely on that behaviour.

I think this would perhaps be a reasonable candidate for a hidden setting.

kookma commented 3 months ago

Thank you @Jermolene. That is fair. One proposal is:

Tiddler: $:/core/ui/ViewTemplate/tags

\whitespace trim
<$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes">
<div class="tc-tags-wrapper"><$list filter="[all[current]tags[]] :sort:alphanumeric:caseinsensitive[subfilter{$:/config/Tags/Sort}]" template="$:/core/ui/TagTemplate" storyview="pop"/></div>
</$reveal>

Here:

I am not sure if the proposed sort flag is suitable or now.

One improvement would be possible rearrangement of tags in edit mode as @twMat proposed. In that way the $:/config/Tags/Sort should be deleted once a tag drag and drop occurs

kookma commented 2 months ago

This has been addressed in https://github.com/Jermolene/TiddlyWiki5/pull/8351

twMat commented 2 months ago

@kookma - that PR does not address this OP. That PR only concerns the tag-picker dropdown sorting.

kookma commented 2 months ago

@twMat Sorry! Yep, it partially resolves the issue! I reopen this ticket.

pmario commented 2 months ago

@kookma There is a new draft-PR which should take care of your issue. The problem here is the Object.keys() handling as I wrote at: https://github.com/Jermolene/TiddlyWiki5/issues/8347#issuecomment-2214053068

We will need to rewrite the tags-operator, which will definitely not land in v5.3.5 since it needs more time to be tested.

There may be a performance impact positive or negative -- We will need more measurements. -- In my initial measurements I did not see a negative impact for tiddlywiki.com. But we will need to test with way more tiddlers and tags 20k-50k

pmario commented 2 months ago

@kookma -- What do you think? Code is not finished yet, but imo it looks promising. (The animated GIF loops 3 times then stops)

tag-original-order

kookma commented 2 months ago

Looks interesting!