This PR fixes https://github.com/django-cms/django-cms/issues/7391 . It is specifically designed for the support/4.0.x branch. Alternatively, use djangocms-text-ckeditor>=5.1.2 which natively supports django CMS versions 4.0.x and 4.1.x.
Inconsistent behaviour when reordering plugins
Reason
When cancelling creating the Text Plugin djangocms-text-ckeditor deletes "ghost" plugin it creates (to be able to allow child plugins) without using the django CMS V4 placeholder api. This leaves a gap in the plugin tree. Django CMS v4 internal plugin tree code assumes all child plugins being consecutively positioned right after the parent plugin to allow to move them. The gap breaks the assumption and the move fails. After a second move operation the tree assumes the plugin already is at the position it is being moved to. Any move attempt fails.
Plugin trees might remain broken.
Solution
Using the cms v4 placeholder api automatically takes care of any gaps and closes them.
Extension
Then creating the ghost plugin djangocms-text-ckeditor replicates the CMS v4 internal code. This pr could be amended by replacing the code duplication by also using cms' placeholder api to create the ghost plugin. The step can be added to the pr upon request of the reviewers.
This PR fixes https://github.com/django-cms/django-cms/issues/7391 . It is specifically designed for the
support/4.0.x
branch. Alternatively, usedjangocms-text-ckeditor>=5.1.2
which natively supports django CMS versions 4.0.x and 4.1.x.Inconsistent behaviour when reordering plugins
Reason
When cancelling creating the Text Plugin djangocms-text-ckeditor deletes "ghost" plugin it creates (to be able to allow child plugins) without using the django CMS V4 placeholder api. This leaves a gap in the plugin tree. Django CMS v4 internal plugin tree code assumes all child plugins being consecutively positioned right after the parent plugin to allow to move them. The gap breaks the assumption and the move fails. After a second move operation the tree assumes the plugin already is at the position it is being moved to. Any move attempt fails.
Plugin trees might remain broken.
Solution
Using the cms v4 placeholder api automatically takes care of any gaps and closes them.
Extension
Then creating the ghost plugin djangocms-text-ckeditor replicates the CMS v4 internal code. This pr could be amended by replacing the code duplication by also using cms' placeholder api to create the ghost plugin. The step can be added to the pr upon request of the reviewers.
Repairing broken plugin trees
The brave can try repairing already broken plugin trees at their own risk using https://github.com/fsbraun/djangocms4-utilities