Undo / redo on modified arrays leads to duplicated data

Hi @philipaarseth,

What you really seem to want is a “move” feature in Yjs (that’s something that I’ve been working on). “moving of elements” will guarantee that there will be only one identity of each element. Moving an element twice shouldn’t result in duplication.

This issue has also been discussed in:

Now, this doesn’t solve your issue because the new move feature will not (yet) support moving between arrays. One simple solution, that I also suggested in the thread, is to have some kind of “cleanup” function that remove duplicate elements. It should consistently remove the same element (e.g. always the last element) to ensure that all clients end up with the same content without deleting the element entirely. A case you want to prevent is that user A cleans up the first duplicate, and user B cleans up the second duplicate.