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 0e7234699acc3..34bde89d87e43 100644
--- a/addons/website/static/src/snippets/s_image_gallery/options.js
+++ b/addons/website/static/src/snippets/s_image_gallery/options.js
@@ -112,9 +112,8 @@ options.registry.gallery = options.Class.extend({
save: images => {
// TODO In master: restore addImages Promise result.
this.trigger_up('snippet_edition_request', {exec: () => {
- 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,
@@ -122,15 +121,10 @@ options.registry.gallery = options.Class.extend({
'data-name': _t('Image'),
style: $images.length > 0 ? $images[0].style.cssText : '',
}).appendTo($container);
- if (!$newImageToSelect) {
- $newImageToSelect = $img;
- }
}
if (images.length > 0) {
return this._modeWithImageWait('reset', this.getMode()).then(() => {
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 99cee0ea8c37d..6aeab19e166c3 100644
--- a/addons/website/static/tests/tours/snippet_image_gallery.js
+++ b/addons/website/static/tests/tours/snippet_image_gallery.js
@@ -92,3 +92,32 @@ wTourUtils.registerWebsitePreviewTour("snippet_image_gallery_reorder", {
trigger: ".snippet-option-ImageTools we-select:contains('Filter') we-toggler:contains('Blur')",
run: () => null, // This is a check.
}]);
+
+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("gallery", "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'])",
+ run: () => null, // This is a check.
+}, {
+ 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)']",
+ run: () => null, // This is a check.
+}]);
diff --git a/addons/website/tests/test_snippets.py b/addons/website/tests/test_snippets.py
index 2b8f20908582a..05e3e6f6a9bbc 100644
--- a/addons/website/tests/test_snippets.py
+++ b/addons/website/tests/test_snippets.py
@@ -110,3 +110,14 @@ def test_drag_and_drop_on_non_editable(self):
def test_snippet_image_gallery_reorder(self):
self.start_tour("/", "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('/', 'snippet_image_gallery_thumbnail_update', login='admin')