[BUG] Wrong HTML id generated for modular content field in a block

How I discover the bug:

  • Conditional fields plugin not working for modular content target in a block.
  • Conditional fields plugin works fine with modular content target in a model.
  • Conditional fields plugin works fine with text field in a block.
  • After checking the conditional fields plugin code, I found out that the HTML id generated for modular content field inside a block is wrong.

Reproduce steps:

  1. Create a block with a boolean field with conditional field plugin + a modular content field (named rich field) (it can reference to any other blocks).
  2. Update conditional field settings to show/hide above modular content field.
  3. Create a model with a modular content field (named test block) with above block as allowed value.
  4. Go to content and see that toggle the boolean field doesn’t show/hide the modular field.

Possible root cause:
After I dived into the conditional fields repo, I found out that it uses ctx .toggleField with a targetPath to do the job.
So for above modular content inside a block, the target path should be something like test_block.0.rich_field and the html id for it should be field--test_block.0.rich_field
But, after checking the html of the content editor, the id for that field is just field--rich_field . The id for other type of field such as text is correct, only modular content has this issue.
So maybe there’s a bug when generate the html id for modular content field inside a block?

Follow up question:
I tried to run a fork of conditional field repo and start a private plugin, then I update the target path of the modular content field in a block to not have the parent fieldPath , and just be field--rich_field to try to get it to work as a temporary solution, but this also doesn’t work. Do you have any idea for a workaround for this?

1 Like

Hello @itsmetambui and welcome to the community!

I was able to reproduce the error locally, with your step by step.
I’ve contacted the dev team, and i’ll get back to you as soon as possible

Thank you so much for the detailed report!

1 Like

@m.finamor thank you for the quick reply, looking forward to it.

We found the issue, it’s already fixed in production @itsmetambui!

1 Like

Lightning fast! That’s awesome, thank you so much @s.verna !