Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Multiple conditional fields behave peculiarly when the condition of one assesses the state of the other #15104

Closed
JamieC24 opened this issue May 30, 2024 · 8 comments
Assignees
Labels

Comments

@JamieC24
Copy link

What happened?

Description

I have created an Entry Type that uses an Entries field and a URL field.

The Entries field is conditionally set to appear only when the URL field is empty.

The URL field is conditionally set to appear only when the Entries field is empty.

Both fields are visible to begin with (as expected, as both are empty at this point)

When I populate the URL field, the Entries field disappears (as expected)

When I remove the content from the URL field, the Entries field reappears (as expected)

When I select an Entry from the Entries field, the Entries field disappears and the URL field reappears with the content it had before I removed the content from it.

If I refresh the page, neither of the fields are visible (presumably because the state of both is 'has a value' and the fields are both set to appear only when the other has a state of 'is empty')

Steps to reproduce

  1. Log in to any Craft 5.1.7 install
  2. Create an Entry Type
  3. Save the Entry Type
  4. Create a couple of Entries that use the Entry Type you created
  5. Edit your Entry Type using Settings -> Entry Types -> [Your Entry Type]
  6. Create an Entries field and add it to the "Content" tab of your Entry Type
  7. Create a URL field and add it to the "Content" tab of your Entry Type
  8. Edit the settings of your Entries field by clicking on the three dots on the far right of the field box and selecting "Settings"
  9. Use the "Entry Condition" section to add a rule that maps to your URL field and checks that it "is empty" (the dropdown for this shows as 'relates to' by default)
  10. Repeat this process for the URL field, mapping its conditional rule to the Entries field.
  11. Save your Entry Type
  12. Go to one of the two Entries you created and put something in the URL field (e.g https://www.google.ie/)
  13. Remove the text you've just added by highlighting "https://www.google.ie/" and pressing the backspace key
  14. Your Entries field should reappear now. Click the "Add an entry" button on it, select the other entry you created and click "Select"

Expected Behaviour

When you press "Select", a small representation of the entry you chose should appear under the heading for your Entries field, and the URL field should not be visible

Actual Behaviour

When you press "Select", the Entries field disappears and is replaced by the URL field that has repopulated itself with whatever you populated it with previously (e.g https://www.google.ie/).
If you refresh the page and scroll to where your field was, you should no longer be able to see the Entries field nor the URL field.

Craft CMS version

Craft CMS Pro 5.1.7

PHP version

8.2.0

Operating system and version

MacOS Sonoma 14.5

Database type and version

PostgreSQL 15.8

Image driver and version

No response

Installed plugins and versions

  • CKEditor 4.0.5
  • Feed Me 6.1.0
  • Postmark 3.1.0
@JamieC24 JamieC24 added the bug label May 30, 2024
@i-just
Copy link
Contributor

i-just commented May 30, 2024

Hi, thanks for getting in touch! I’m not able to reproduce this behaviour. Do you see any errors in the console when editing this entry?

@JamieC24
Copy link
Author

I just retested this on my local following the steps above and it seems like this doesn't happen when you first set it up, but if you populate the URL field, then save it, then refresh the entry, then do steps 13 and 14, that's when the problem happens!

Would you be able to test this happens for you as well?

@i-just
Copy link
Contributor

i-just commented May 30, 2024

Thanks for the update. Unfortunately, I’m still not able to replicate this. I take it you don’t see anything in the console when this happens for you?

@JamieC24
Copy link
Author

How strange!

I'm not seeing any errors in the console, but there are a few warnings - I've attached a screenshot of the warnings I'm getting below:
Screenshot 2024-05-30 at 12 06 32

I'm happy to demonstrate the issue I'm getting on a call if that's helpful?

@i-just
Copy link
Contributor

i-just commented May 30, 2024

Thanks for confirming! Would you be able to send your composer.json, composer.lock and database export to support@craftcms.com and point out which entry should be edited as per your instructions so that we can reproduce and dig deeper?

@JamieC24
Copy link
Author

Sure! I'll do that now ☺️

@i-just
Copy link
Contributor

i-just commented May 30, 2024

Thanks! The missing piece of the puzzle was that the fields are part of a matrix field which has inline-editable blocks view mode. Looking into it.

@brandonkelly
Copy link
Member

Craft 5.1.8 is out with that fix. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants