From b01684375326de1ba13a107c2ccae38729b02eb7 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 19 Apr 2023 08:40:06 +0000 Subject: [PATCH] [FIX] website: avoid failing switching mode while image is selected Since [1] an error is raised when switching the Mode of an Images Wall from Float to Grid or Masonry while an image is selected. The display of the size of the image is being updated while its option panel is not there anymore. This commit prevents this error from happening by setting up the grid layout with clones of the images instead of the images themselves. This leads to the construction of a new editor for the new image. Steps to reproduce: - Drop an Images Wall snippet. - Switch Mode to Float. - Select an image. - Switch Mode to Grid. => Traceback. [1]: https://github.com/odoo/odoo/commit/2cbb691a84ce186ddd34a2a4c76d95671ed6e834 task-2990053 closes odoo/odoo#125436 X-original-commit: c532bc6c3b861a68e8381f39efaa22201ae253cb Signed-off-by: Benjamin Vray (bvr) --- addons/website/static/src/snippets/s_image_gallery/options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/static/src/snippets/s_image_gallery/options.js b/addons/website/static/src/snippets/s_image_gallery/options.js index db5cd4bca50..9088de7f03b 100644 --- a/addons/website/static/src/snippets/s_image_gallery/options.js +++ b/addons/website/static/src/snippets/s_image_gallery/options.js @@ -164,7 +164,7 @@ options.registry.gallery = options.Class.extend({ var $container = this._replaceContent($row); imgs.forEach((img, index) => { - var $img = $(img); + const $img = $(img.cloneNode()); var $col = $('
', {class: colClass}); $col.append($img).appendTo($row); if ((index + 1) % columns === 0) {