cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

CollectionPropertyContainer replaces the wrong item in the master entity field #3221

Closed gorbunkov closed 3 years ago

gorbunkov commented 3 years ago

Environment

Description of the bug or enhancement

Sample project: dc-sort-demo.zip

Given:

Steps to reproduce the issue:

  1. Open existing order (example with 2 items)
  2. Edit 1st item (“Cup”) and set price to 100 (and save)
  3. Sum in table is 130, but sum in field is 200

Analysis:

The order items table is sorted by the "Product" column - that's why the order of elements in the order items collection in order.items collection and in the collection container are different (sorting affects only collection container)

CollectionContainerImpl.replaceItem() evaluates the modified element index inside the CollectionPropertyContainer collection and then replaces the element with this index in the order.items property master collection, but elements order in both collections is different because of sorting

Forum topic: https://forum.cuba-platform.com/t/merge-compostion-in-editor-overrides-wrong-item/15588