TiddlyWiki / TiddlyWiki5

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

[BUG] Some issues with $action-listops de-duplication #7266

Open yaisog opened 1 year ago

yaisog commented 1 year ago

Describe the bug

$filter output is de-duplicated before being written to the target field.

Expected behavior

No de-duplication. Or, if it's intended, a corresponding explanation in the docs.

To Reproduce

  1. Go to tiddlywiki.com
  2. Create a tiddler with the text <$button actions="""<$action-listops $tiddler="$:/temp/listops" $filter="[[1]] =[[1]]" />""">Click</$button>
  3. Click the button
  4. Look at the list field of $:/temp/listops

Screenshots

No response

TiddlyWiki Configuration

5.2.5

Additional context

No response

yaisog commented 1 year ago

OK, so this de-duplication seems only to happen to the list field, so I guess it's intentional. However, since list is the default field for the widget, it should be documented (unless it is a bug).

Seems that the same de-duplication goes for $action-setfield when setting the list field.

If someone can confirm that this is the intended behavior, I can prepare a doc update PR.

yaisog commented 1 year ago

Also, the input to the $subfilter of $action-listops is de-duplicated without notice, so $subfilter cannot be used when the list possibly contains duplicates, and one currently has to resort to $filter="[enlist:raw[...]" to enlist the current list.

pmario commented 1 year ago

I think you should add your info to the docs. We cannot change the intrinsic behaviour because of backwards compatibility concerns. ...

There will probably be some code that relies on the current behaviour, especially as de-duplication was default for everything from the start of TW.

Duplicates where implemented at a much later date. There are probably many cases where it does not work as expected.

On the other hand, where duplicates are explicitly requested by the user they should work.

Create a tiddler with the text <$button actions="""<$action-listops $tiddler="$:/temp/listops" $filter="[[1]] =[[1]]" />""">Click</$button>

So if there is a workaround it should be documented.

So I think, the behaviour of the OP is a bug

I did not read the corresponding code, since listops is a bit hacky. ... BUT I did have a similar problem with one of my plugins, where I want to implement drag&drop sorting for filter strings, which also can have duplicates.

I think I did ended up using enlist:raw too, but in listops functions some filters are hadcoded ... which needs to be fixed.