verbb / vizy

A flexible visual editor for Craft CMS
Other
43 stars 8 forks source link

Vizy not working in Neo v3.9 #260

Open stevendierick opened 9 months ago

stevendierick commented 9 months ago

Describe the bug

Vizy in a Neo block won't initialize anymore since the new Neo v3.9 updates. Works perfectly fine on Neo v3.8.6.

Tested with parent and child blocks:

Steps to reproduce

  1. Add Vizy field to Neo block
  2. Add your Neo block with Vizy to your page

Craft CMS version

4.5.5

Plugin version

2.1.9

Multi-site?

No

Additional context

Neo plugin version: 3.9.2

engram-design commented 9 months ago

Judging from the error message, this seems a Neo issue?

image

I can confirm the check here fails.

ttempleton commented 9 months ago

If I'm understanding the purpose of _isRootField() correctly (making sure the element doesn't exist inside a Vizy block), then the recursive call with the Neo block's owner is unnecessary since Neo fields are disallowed from being nested in other block element fields.

engram-design commented 9 months ago

Hmm, you make a good point! This function is there for complicated reasons with Vizy to check if it's a nested Vizy field, but to handle complex situations like Vizy > Neo > Vizy > Neo > etc. So there is a use-case for us to travel up the element "tree" to see how the structure is.

From what I can tell with Neo, this seems to be because we're calling things early before the parent element has time to be populated. Looking into what I can do on my end about this.

ttempleton commented 9 months ago

The underlying change in Neo 3.9 is that the first creation of a block of a given type will now lazy load the block type's field layout tabs, rather than having it all loaded on page load when many block types may not be used. This involves creating a new Neo block instance of that type to then render its tabs, and it turned out that we weren't passing through the owner ID, which caused this error. I've added the fix https://github.com/spicywebau/craft-neo/commit/afc6b45f6dfc364c6d2249a5bbece47e77b3088d which will be included in the next release.

engram-design commented 9 months ago

Nice, thanks @ttempleton !