From caf1ca67e9e6787382df486a4b9dcc1bcf58c8fa Mon Sep 17 00:00:00 2001 From: "Guillaume (gdi)" Date: Fri, 29 Jul 2022 09:44:53 +0000 Subject: [PATCH] [FIX] website: permit to open the image wall modal correctly Since the bootstrap 5 merge at [1], when you click on an image in the Image Wall block, the modal no longer opens. This commit restores that and adds a test to make sure this problem does not happen again. Steps to reproduce: - Drop the "Image wall" block in a page - Save - Click on an image -> The modal does not open [1]: https://github.com/odoo/odoo/commit/971e5a91aab96d36129a823e03f1f9f1b1293968 task-2937538 closes odoo/odoo#97053 Signed-off-by: Quentin Smetz (qsm) --- .../src/snippets/s_image_gallery/000.js | 10 +++------ .../src/snippets/s_image_gallery/000.xml | 4 ++-- .../src/snippets/s_image_gallery/001.scss | 3 --- .../tests/tours/snippet_image_gallery.js | 22 +++++++++++++++++++ addons/website/tests/test_snippets.py | 3 +++ 5 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 addons/website/static/tests/tours/snippet_image_gallery.js diff --git a/addons/website/static/src/snippets/s_image_gallery/000.js b/addons/website/static/src/snippets/s_image_gallery/000.js index eff0a67371a..82b23d82864 100644 --- a/addons/website/static/src/snippets/s_image_gallery/000.js +++ b/addons/website/static/src/snippets/s_image_gallery/000.js @@ -50,24 +50,20 @@ const GalleryWidget = publicWidget.Widget.extend({ interval: milliseconds || 0, id: _.uniqueId('slideshow_'), })); - $modal.modal({ - keyboard: true, - backdrop: true, - }); $modal.on('hidden.bs.modal', function () { $(this).hide(); $(this).siblings().filter('.modal-backdrop').remove(); // bootstrap leaves a modal-backdrop $(this).remove(); }); - $modal.find('.modal-content, .modal-body.o_slideshow').css('height', '100%'); - $modal.appendTo(document.body); - $modal.one('shown.bs.modal', function () { self.trigger_up('widgets_start_request', { editableMode: false, $target: $modal.find('.modal-body.o_slideshow'), }); }); + $modal.appendTo(document.body); + const modalBS = new Modal($modal[0], {keyboard: true, backdrop: true}); + modalBS.show(); }, }); diff --git a/addons/website/static/src/snippets/s_image_gallery/000.xml b/addons/website/static/src/snippets/s_image_gallery/000.xml index 1fd8e861bc5..8ce19bf27c9 100644 --- a/addons/website/static/src/snippets/s_image_gallery/000.xml +++ b/addons/website/static/src/snippets/s_image_gallery/000.xml @@ -56,9 +56,9 @@