craftcms / cms

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

[4.x]: Twig template relation condition rules bug in a matrix field #13269

Open mathieuser opened 1 year ago

mathieuser commented 1 year ago

What happened?

Description

When I set-up a Matrix field with one block with functionality as per #12679 , it works as expected: one relation-field filters the second. When I use this set-up on a second block, the page needs to be saved and refreshed before filters apply.

Steps to reproduce

  1. Make a matrix field with one block with 2 relation fields of entry types that are related to eachother.
  2. Test the matrix field and see the filter working
  3. Add another block with the same functionality
  4. See that the filter is only applied after saving / refreshing

Expected behavior

When I have two relation-fields, I want to select the first one, which then acts as a filter for the second one. When the first one is selected, the second one must be filtered on opening.

Actual behavior

This works flawlessly when I have this set-up on only one of the matrix blocks I created. When I add this functionality to a second block, the filter stops working on both blocks, until I save the project and the page reloads, then the second field is filtered again.

https://github.com/craftcms/cms/assets/6756174/67f387e5-4dfd-4def-8a77-245f1cc4a8fd

Craft CMS version

4.4.13

PHP version

8.1

Operating system and version

No response

Database type and version

Mysql

Image driver and version

No response

Installed plugins and versions

-

i-just commented 1 year ago

Hi, thanks for reporting. We’re aware of this and plan to action this in Craft 4.5. For now, reloading the element edit page after adding a block will do the trick.