I created a short Rules Component to move an item from top position to last position.

1) Add an item to a list. I added 'list-item:0' to the end, Enforce uniqueness: False.
==>Works!
2) Remove an item from a list. Item to remove: 'list-item:0'.
==>The action removes both 'list-item:0' and the newly added/cloned last item.

A workaround is to assign a new value to 'list-item:0', then the removal works as intended, the last item remains in the list

Is this a feature or a bug?

/Leiph

Comments

Leiph created an issue. See original summary.

TR’s picture

Status: Active » Closed (works as designed)
Remove an item from a list. Item to remove: 'list-item:0'.
==>The action removes both 'list-item:0' and the newly added/cloned last item.

Lists are not associate arrays. Although the elements are "ordered" by the sequence in which they were added to the list, they are not keyed values. Thus, you can never access list items by key or a numerical index, you can only access them by value.

When you choose an "Item to remove", you could use either direct input mode to specify a VALUE to remove, or you can use the data selector to identify a object holding the VALUE to remove.

So when you choose "list-item:0" in the data selector, that does NOT mean remove index "0" from the list-item array. In this case "list-item:0" is just the name of the object, and it's that name that is fooling you. It could have been called "Bob". When you choose "list-item:0" in the data selector it means remove the element whose VALUE is equal to the value stored in the object "list-item:0" (or "Bob"). Because "unique" is false, this can match one or more items and it will remove them all.