[FIX] web_editor: solve the history bug when dropping out of a dropzone

When dragging a grid item and dropping it outside (near) a dropzone,
and then undoing the operation, the grid item didn't return to its
original state: some removed classes and style properties were not
added back. This would cause the item to be broken and trying to drag
it had unexpected results that could even lead to a traceback.

This behavior was caused by the fact that the grid item was not
attached to any element when these attributes were modified, so the
changes happened "nowhere". This commit fixes that.

task-2973198

X-original-commit: 83c07fcce898225f06f1ba84059a031409db0627
Part-of: odoo/odoo#102525
This commit is contained in:
Soukéina Bojabza
2022-10-06 23:14:40 +02:00
committed by qsm-odoo
parent 318c937d9d
commit f926559823
@@ -1235,6 +1235,7 @@ var SnippetEditor = Widget.extend({
// Some drop zones might have been disabled.
$el = $el.filter(this.$dropZones);
if ($el.length) {
$el.after(this.$target);
// If the column is not dropped inside a dropzone.
if ($el[0].classList.contains('oe_grid_zone')) {
// Case when a column is dropped near a grid.
@@ -1269,7 +1270,6 @@ var SnippetEditor = Widget.extend({
}
}
$el.after(this.$target);
this.dropped = true;
}
}