craftcms / cms

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

[4.x]: Reordering entries in a matrix field in a category doesn't save the new position #11419

Closed PiessensLander closed 2 years ago

PiessensLander commented 2 years ago

What happened?

Description

I'm experiencing some unexpected behavior when using an entry field within a matrix that's used in a category. When I want to reorganize or replace some or all entries in the matrix field, it always changes back to the initial state. For example, when replacing selected entries in the matrix field, they change back to the original entries after saving the category. This behavior also occurs when reorganizing the order of the selected entries. I did however notice that the same matrix field works perfectly fine in an entry, as well as in a draft of a category. This issue is also reflected on the frontend. It's not just a visual bug.

Steps to reproduce

  1. Create a new matrix field
  2. Add a field for entries
  3. Add the matrix field to a category
  4. Add a few entries to the matrix field
  5. Save the category
  6. Edit the ordering of the selected entries in the matrix block
  7. (optional) remove some or all selected entries
  8. Save the category

Expected behavior

The matrix field updates the ordering of the selected entries

Actual behavior

The matrix field goes back to the initial state

Craft CMS version

4.0.4

PHP version

8.1.5

Operating system and version

MacOS 12.4

Database type and version

MySQL 5.7.34

Image driver and version

GD 8.1.5

Installed plugins and versions

brandonkelly commented 2 years ago

Thanks for reporting that! Turns out it wasn’t just relational fields, but any changes made to existing blocks. Fixed now for the next release.

To get the fix early, change your craftcms/cms requirement in composer.json to "dev-develop as 4.0.4" and run composer update.

brandonkelly commented 2 years ago

Craft 4.0.5 is out now with that fix.