verbb / vizy

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

Redactor in Vizy doesn't save any changes #180

Closed ragnarfrosti closed 1 year ago

ragnarfrosti commented 1 year ago

Describe the bug

I use Redactor in a Vizy field. When I write a text in the Redactor-block in the Vizy-field the first time it saves the text.

But, if I edit only the text in the Redactor block an save the entry the Redactor text is not updated.

If I edit the Redactor-block AND some other block that is not a Redactor-block and save the entry the Redactor text is also saved.

Update: The problem only seems to occur if you save the entry while the redactor field has focus and you haven't changed or focused on any other field. If you change the text in the redactor field and click outside the field and then click on the save button then the changes will be saved it seems.

Steps to reproduce

  1. Create a Vizy field
  2. Add Redactor field as a Vizy block
  3. Create a new entry with that Vizy field, write a text in the Redactor block and save
  4. Try to edit only the text in the Redactor block in the Vizy field and save
  5. The text in the Redactor block is not saved and shows the same text from Step 3.

Craft CMS version

4.2.8

Plugin version

2.0.7

Multi-site?

Yes

Additional context

No response

engram-design commented 1 year ago

Hmmm, this would have to do with Vizy's change-detection, which serializes the content generated by the inner fields for a block, into JSON so we can save it all correctly.

However, I can't seem to replicate this, and typing in an already-saved Redactor field and immediately Cmd+S to save the entry does seem to keep changes. In addition, if I type in the field and do nothing, the change is detected by Craft's auto-saving feature (the spinner next to the revisions/site dropdown next to the title).

Is your Vizy field nested per chance?

ragnarfrosti commented 1 year ago

I can see that the auto-saving feature is triggered when I type in the redactor field but the problem with the content of the redactor field persists.

I actually want to mention that sometimes it doesn't save my changes at all and sometime it saves some of the content. Here are two screen recordings of two different cases

  1. Here I change the text and save the entry using cmd+S and it saves just a part of the new text in that field. After that I add some more text and focus on the note field before saving the entry and then it works

https://user-images.githubusercontent.com/4622136/197143545-0ba50d27-c866-4fd9-8e8a-324818b00d0b.mov

  1. In the second example I just remove all the text in the redactor field and save. But the text is still there afterwards.

https://user-images.githubusercontent.com/4622136/197143714-b4d6a6ae-b0d4-46c9-86e1-7a877c9730fe.mov

This is how our Vizy field is setup if that helps:

Screenshot 2022-10-21 at 09 59 03
strandofgenius commented 1 year ago

I am also having this issue when a Redactor field is nested inside a Vizy block. If I do any formatting like bold, italics, or try and link text it removes the formatting when I save the entry.

engram-design commented 1 year ago

@ragnarfrosti So in your first video, your first set of changes don't seem to trigger a changed value event. You can see the track changes indicator in your next lots of edits as you type (to the left of the Vizy field). I just can't seem to get it to not recognise my changes, but I'll keep at it. The partial-save is something I've never seen or come across before, so that's interesting.

But as I mentioned it does have something to do with how we serialize the content inside a Vizy block so it can be saved as JSON content, which is tricky for all sort of different fields that use jQuery and others. Clicking outside of the block will trigger this, but it's likely happening too quick in some instances.

ax2000 commented 1 year ago

I'm also experiencing this issue. When performing changes to the Redactor field, the form submits correctly and I get the "Entry saved" toast message but when opening the form again the changes are not there.

Craft 4.3.1 Vizy 2.0.9

engram-design commented 1 year ago

Fixed in 2.1.0