django-cms / djangocms-text-ckeditor

Text Plugin for django CMS using CKEditor 4
https://www.django-cms.org/en/repositories-plugins/
BSD 3-Clause "New" or "Revised" License
164 stars 186 forks source link

The old plugin content is deleted after clicking cancel with new nested plugins #641

Closed sgordeychuk closed 8 months ago

sgordeychuk commented 1 year ago

Steps to reproduce

  1. Create a Text plugin with some simple text content
  2. Save and publish the page
  3. Go to edit mode again and edit the same Text plugin
  4. Add any plugin using CMS Plugins menu
  5. Click cancel
  6. Reload the page

Expected result

Only new nested plugin was removed, but the text content and old plugins remains the same

Actual result

The whole content of plugin is cleared, the whole old published content is lost

Analysis

I've tried to debug the issue and found that cms.admin.placeholderadmin.PlaceholderAdminMixin.edit_plugin is called on Cancel click because newly created plugins should be cleared, which is make sense. Although inside that method I can see that new Text plugin instance is created, then plugins which are not needed should be cleared. But even adding plugin.body = obj.body there doesn't help, because it's being overwritten somewhere inside in operations.CHANGE_PLUGIN calls.

Do you have any ideas where to look at? I have a feeling that it's something with post_placeholder_operation call which doesn't copy the content from the old plugin, but not sure.

djangocms-test-ckeditor==5.1.1 (also reproducible with 5.1.2) djangocms==3.9.0 (but also reproducible with 3.11.1)

fsbraun commented 1 year ago

@sgordeychuk Thanks for this excellent bug report!

sveetch commented 1 year ago

I reproduce it also with djangocms-text-ckeditor==5.1.2 and django-cms==3.11.1, i encountered this behavior and i thought about configuration problems before to search and see your report.

I wonder if a downgrade to djangocms-test-ckeditor<=5.1.1 could fix this temporarily, however a new migration have been passed in previous release so it's not a workaround for those ones that already upgraded recently..

DmytroLitvinov commented 9 months ago

The same issue in our project. Project setup:

DmytroLitvinov commented 9 months ago

@fsbraun , @marksweb , hello.

Do we know when we can release new version of djangocms-text-ckeditor to pypi where there is such important fix?

fsbraun commented 9 months ago

@DmytroLitvinov Here's the PR: https://github.com/django-cms/djangocms-text-ckeditor/pull/653

sgordeychuk commented 8 months ago

@fsbraun thanks a lot for the fix! I've tested it with my setup and everything works great now. Should I close the ticket or will you do it?

fsbraun commented 8 months ago

Just done! Thanks ;-)