From 009f259b0b2a605c23a0c3bb01507760d1c97367 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 7 Jun 2023 13:58:08 +0000 Subject: [PATCH] [FIX] web_editor: make moving images within wall wrap around When using the previous button in an image wall, the image wraps around but skips the last position. When using the next button in an image wall, the image does not wrap around. This commit fixes this inconsistency by using the same behavior as the one in 15.0 since [1]: wrap through all positions in both directions. Steps to reproduce: - Drop an "Images Wall" snippet. - Add 6 images. - Select an image. - Click repeatedly on "Move to previous". => The image wraps around all positions except the last one. - Click repeatedly on "Move to next". => The image does not move anymore once it reached the last position. [1]: https://github.com/odoo/odoo/commit/3931f0a67f904daea6c891a3a80aa984760a7682 task-2990053 X-original-commit: 054f480376e8d08d1582cedd6caec6455be828e2 Part-of: odoo/odoo#125758 --- addons/web_editor/static/src/js/editor/snippets.options.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index ce690129a6a..37ef44da2ea 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -8318,6 +8318,11 @@ registry.GalleryHandler = SnippetOptionWidget.extend({ if (name === "reoder_items") { const itemsEls = this._getItemsGallery(); const oldPosition = itemsEls.indexOf(data.itemEl); + if (oldPosition === 0 && data.position === "prev") { + data.position = "last"; + } else if (oldPosition === itemsEls.length - 1 && data.position === "next") { + data.position = "first"; + } itemsEls.splice(oldPosition, 1); switch (data.position) { case "first":