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:
- 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). - Update conditional field settings to show/hide above modular content field.
- Create a model with a modular content field (named
test block
) with above block as allowed value. - 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?