spicywebau / craft-neo

A Matrix-like field type for Craft CMS that uses existing fields
Other
403 stars 63 forks source link

Child block disappears after autosave #861

Open ccchapman opened 4 months ago

ccchapman commented 4 months ago

Bug Description

A newly created child block disappears after autosave.

Steps to reproduce

  1. Create an entry
  2. Add a Neo block at the root level
  3. Add a child Neo block to that block
  4. Populate field values on that child Neo block
  5. Wait for the autosave to finish
  6. Child Neo block disappears from screen

Expected behaviour

No response

Neo version

4.0.6

But we think we had the issue on 4.0.5 too.

Craft CMS version

4.8.0

What is the affected Neo field's propagation method?

"all" but the owner element is "none"

Does this issue involve templating, and if so, is eager-loading used?

This is not a templating issue

ccchapman commented 4 months ago

I have emailed in a screen recording of the issue in case any additional relevant details are observed.

ccchapman commented 4 months ago

We searched through Craft logs and found some errors which may or may not be relevant. These errors happened close to the times we have observed issues.

2024-03-05 08:58:16 [web.ERROR] [yii\web\HttpException:400] Invalid draft ID: 375
2024-03-05 08:33:36 [web.ERROR] [yii\web\HttpException:400] Invalid draft ID: 368

We have seen these types of requests for admin/actions/elements/recent-activity and admin/actions/elements/save-draft.

ttempleton commented 4 months ago

That is a pretty weird one, looking at the screen recording, since it doesn't even happen after the first edit of the child block.

If possible, could you please email the composer files and database backup, and we'll have a look.

ccchapman commented 4 months ago

That is a pretty weird one, looking at the screen recording, since it doesn't even happen after the first edit of the child block.

If possible, could you please email the composer files and database backup, and we'll have a look.

Thank you, Thomas. I have sent the files.

I have not been able to reproduced the issue myself. We have a user that has encountered it many times in the last two weeks.

ttempleton commented 3 months ago

Thanks for sending those. I'm unable to reproduce it either, so far. I'm guessing it's a timing issue with draft autosaves and Neo updating visible field layout elements, like #823. (Last I checked, updating of visible field layout elements for inline Matrix blocks in Craft 5 worked very similarly to how it currently works for Neo, so my comments in #823 are unfortunately irrelevant.)

Given that this issue involves the use of a child block UI element, a possible workaround is to remove the UI element, since it seems like the updating of visible field layout elements is causing the UI element contents to be reset.

ccchapman commented 3 months ago

Given that this issue involves the use of a child block UI element, a possible workaround is to remove the UI element, since it seems like the updating of visible field layout elements is causing the UI element contents to be reset.

Thank you for the suggestion. We will test removing the "Child Blocks" UI element from the block type field layout.

ccchapman commented 3 days ago

Could this be the same as #891?

ttempleton commented 2 days ago

I don't think that's the same since #891 only happened when saving as a new entry, not during autosave.

Recent changes could have potentially resolved this, though; have you had it happen recently?

ccchapman commented 2 days ago

Recent changes could have potentially resolved this, though; have you had it happen recently?

We have not seen it again; however, we still have the child blocks UI element removed.