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 a52591554e5..8e43b81417c 100644
--- a/addons/website/static/src/snippets/s_image_gallery/options.js
+++ b/addons/website/static/src/snippets/s_image_gallery/options.js
@@ -446,9 +446,8 @@ options.registry.GalleryImageList = options.registry.GalleryLayout.extend({
multiImages: true,
onlyImages: true,
save: images => {
- let $newImageToSelect;
for (const image of images) {
- const $img = $('
', {
+ $('
', {
class: $images.length > 0 ? $images[0].className : 'img img-fluid d-block ',
src: image.src,
'data-index': ++index,
@@ -456,15 +455,10 @@ options.registry.GalleryImageList = options.registry.GalleryLayout.extend({
'data-name': _t('Image'),
style: $images.length > 0 ? $images[0].style.cssText : '',
}).appendTo($container);
- if (!$newImageToSelect) {
- $newImageToSelect = $img;
- }
}
if (images.length > 0) {
savedPromise = this._relayout();
this.trigger_up('cover_update');
- // Triggers the re-rendering of the thumbnail
- $newImageToSelect.trigger('image_changed');
}
},
};
diff --git a/addons/website/static/tests/tours/snippet_image_gallery.js b/addons/website/static/tests/tours/snippet_image_gallery.js
index 31999540fce..ede31f9d9c9 100644
--- a/addons/website/static/tests/tours/snippet_image_gallery.js
+++ b/addons/website/static/tests/tours/snippet_image_gallery.js
@@ -91,3 +91,32 @@ wTourUtils.registerWebsitePreviewTour("snippet_image_gallery_reorder", {
trigger: "iframe .s_image_gallery .carousel-item.active img[data-index='1'][data-gl-filter='blur']",
isCheck: true,
}]);
+
+wTourUtils.registerWebsitePreviewTour("snippet_image_gallery_thumbnail_update", {
+ test: true,
+ url: "/",
+ edition: true,
+}, () => [
+ wTourUtils.dragNDrop({
+ id: "s_image_gallery",
+ name: "Image Gallery",
+ }),
+ wTourUtils.clickOnSnippet({
+ id: "s_image_gallery",
+ name: "Image Gallery",
+ }),
+ wTourUtils.changeOption("GalleryImageList", "we-button[data-add-images]"),
+{
+ content: "Click on the default image",
+ trigger: ".o_select_media_dialog img[title='s_default_image.jpg']",
+},
+ wTourUtils.addMedia(),
+{
+ content: "Check that the new image has been added",
+ trigger: "iframe .s_image_gallery:has(img[data-index='3'])",
+ isCheck: true,
+}, {
+ content: "Check that the thumbnail of the first image has not been changed",
+ trigger: "iframe .s_image_gallery ul.carousel-indicators li:first-child[style='background-image: url(/web/image/website.library_image_08)']",
+ isCheck: true,
+}]);
diff --git a/addons/website/tests/test_snippets.py b/addons/website/tests/test_snippets.py
index 30ad0d656fa..1583a55dcd7 100644
--- a/addons/website/tests/test_snippets.py
+++ b/addons/website/tests/test_snippets.py
@@ -115,3 +115,14 @@ class TestSnippets(HttpCase):
def test_snippet_image_gallery_reorder(self):
self.start_tour(self.env['website'].get_client_action_url('/'), "snippet_image_gallery_reorder", login='admin')
+
+ def test_snippet_image_gallery_thumbnail_update(self):
+ IrAttachment = self.env['ir.attachment']
+ base = 'http://%s:%s' % (HOST, config['http_port'])
+ IrAttachment.create({
+ 'public': True,
+ 'name': 's_default_image.jpg',
+ 'type': 'url',
+ 'url': base + '/web/image/website.s_banner_default_image',
+ })
+ self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_image_gallery_thumbnail_update', login='admin')