From ceb68cc6001e8fd0922b53102d808981a82dcaf3 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Tue, 11 Oct 2022 07:31:18 +0000 Subject: [PATCH] [FIX] web_editor: fix moving inner content in carousel slides Before this commit, when moving inner content inside a carousel slide (with the 'move' button), the carousel was jumping to the first slide. Steps to reproduce the bug: - In website edit mode, drag and drop a Carousel snippet onto the page. - Move to the second slide. - Click on the column to activate its overlay. - Click and hold the "drag and drop" button of the column to start dragging it. - Release the mouse button. - Bug: the carousel jumps to the first slide. task-3006831 closes odoo/odoo#114067 X-original-commit: a09031d5f68de5d23bd9cab1910c6f9c50ad7cfd Signed-off-by: Benoit Socias (bso) --- .../web_editor/static/src/js/editor/snippets.editor.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index ea88eb34da0..52820cc033c 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -3641,11 +3641,14 @@ var SnippetsMenu = Widget.extend({ */ _onSnippetDragAndDropStop: async function (ev) { this.snippetEditorDragging = false; - const $modal = ev.data.$snippet.closest('.modal'); + const modalEl = ev.data.$snippet[0].closest('.modal'); + const carouselItemEl = ev.data.$snippet[0].closest('.carousel-item'); // If the snippet is in a modal, destroy editors only in that modal. // This to prevent the modal from closing because of the cleanForSave - // on each editors. - await this._destroyEditors($modal.length ? $modal : null); + // on each editors. Same thing for 'carousel-item', otherwise all the + // editors of the 'carousel' are destroyed and the 'carousel' jumps to + // first slide. + await this._destroyEditors(carouselItemEl ? $(carouselItemEl) : modalEl ? $(modalEl) : null); await this._activateSnippet(ev.data.$snippet); }, /**