craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 626 forks source link

[3.x]: Duplicated entries/categories/products in relation fields #12949

Closed pierrestoffe closed 1 year ago

pierrestoffe commented 1 year ago

What happened?

Description

We noticed that the relation fields weren't working as they used to. When I had content in a relation field (Entries, Categories, Products,…) the elements which were already listed in the field are listed a second time. Here is a video showing the issue.

https://user-images.githubusercontent.com/1706605/226870516-f92265a6-aa41-46e6-aa74-cb5df7f9e8d8.mp4

This issue is only experienced when populating an empty field. It doesn't occur when editing a field which has already been saved with content and still holds content. It happens when creating Entries and Commerce Products and has been tested on multiple browsers and multiple projects running on the same version.

Expected behavior

  1. Create a new entry
  2. Edit a relation field with a limit >= 3 (maybe >=2 too, not tested)
  3. Select one element (element A)
  4. Select a second element (element B)
  5. Notice that the relation field is now element A - element B
  6. Select a third element (element C)
  7. Notice that the relation field is now element A - element B - element C

Actual behavior

  1. Create a new entry
  2. Edit a relation field with a limit >= 3 (maybe >=2 too, not tested)
  3. Select one element (element A)
  4. Select a second element (element B)
  5. Notice that the relation field is now element A - element A - element B
  6. Select a third element (element C)
  7. Notice that the relation field is now element A - element A - element B - element A - element B - element C

Craft CMS version

3.8.5

PHP version

8.1.13

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

i-just commented 1 year ago

Hi, thanks for reporting and for the detailed steps. I submitted a PR for it.

brandonkelly commented 1 year ago

Fixed for the next release!

brandonkelly commented 1 year ago

Craft 3.8.6 and 4.4.6 are out with that fix 🎉