the 1st case
Steps to Reproduce
- run the code with 10.2.0-jakarta.FL.20250506-Eval
<zk> <zscript><![CDATA[ ListModelList model = new ListModelList(List.of("aaa", "bbb", "ccc", "ddd")); ]]></zscript> <button label="move 'aaa' to the end" onClick='model.remove("aaa"); model.add(3, "aaa");Clients.log("" + model);'></button> <button label="move 'bbb' to the start" onClick='model.remove("bbb"); model.add(0, "bbb");Clients.log("" + model);'></button> <button label="move 'ddd' to second" onClick='model.remove("ddd"); model.add(1, "ddd");Clients.log("" + model);'></button> <div> <forEach items="${model}"> <div> <label value="${each}"/> </div> <div> <label value="--- ${each} ---"/> </div> </forEach> </div> </zk>
- click "move 'bbb' to the start" button, check the result
Current Result
forEach doesn't render bbb as the first item
aaa bbb --- bbb --- --- aaa --- ccc --- ccc --- ddd --- ddd ---
Expected Result
bbb --- bbb --- aaa --- aaa --- ccc --- ccc --- ddd --- ddd ---
the 2nd case
Steps to Reproduce
- run the code with 10.2.0-jakarta.FL.20250506-Eval
<zk> <zscript><![CDATA[ ListModelList model = new ListModelList(List.of("aaa", "bbb", "ccc", "ddd")); public void insertBefore(dragged, dropTarget) { String dragItem = dragged.getAttribute("item"); String dropItem = dropTarget.getAttribute("item"); if (dragItem.equals(dropItem)) { return; } model.remove(dragItem); model.add(model.indexOf(dropItem) + 1, dragItem); } ]]></zscript> <div> <div droppable="true" onDrop="insertBefore(event.dragged, self)"> ----</div> <forEach items="${model}"> <div draggable="true" style="height: 30px; background-color: sandybrown;"> <custom-attributes item="${each}"/> <label value="${each}"/> </div> <div droppable="true" onDrop="insertBefore(event.dragged, self)"> <custom-attributes item="${each}"/> ----</div> </forEach> </div> </zk>
- drag aaa and drop to the line below bbb
Current result
---- bbb ---- ccc aaa ---- ---- ddd ----
Expected result
bbb is the 1st item
aaa is the 2nd item
---- bbb ---- aaa ---- ccc ---- ddd ----
Debug Information
- it's a regression bug. It doesn't happen in 10.1.0
Workaround
surround the 2 children inside the <forEach> with a <nodom>