From 400fa9e9f46d60332798454cf90e2e4f395d4da0 Mon Sep 17 00:00:00 2001 From: "Guillaume (gdi)" Date: Fri, 9 Sep 2022 13:02:35 +0000 Subject: [PATCH] [FIX] website: permit to save when two TOC are on the same page Since [this commit], when dropping several "table of content" blocks on the same page, it was impossible to save. This commit solves this problem. Steps to reproduce the resolved bug: - In edit mode, drop two TOC blocks - Click on Save => the UI is blocked [this commit]: https://github.com/odoo/odoo/commit/06b03ba5ef8375b1236f6ecb52ac468124e910ba Related to opw-3047375 Related to opw-3035502 task-2948895 X-original-commit: a6de596017cdbd0da10b4050da132d46dc82a491 Part-of: odoo/odoo#107732 --- .../static/src/snippets/s_table_of_content/000.js | 5 ++++- .../tests/tours/snippet_table_of_content.js | 15 +++++++++++++++ addons/website/tests/test_snippets.py | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 addons/website/static/tests/tours/snippet_table_of_content.js diff --git a/addons/website/static/src/snippets/s_table_of_content/000.js b/addons/website/static/src/snippets/s_table_of_content/000.js index 4399095fc3f..d02d56c2137 100644 --- a/addons/website/static/src/snippets/s_table_of_content/000.js +++ b/addons/website/static/src/snippets/s_table_of_content/000.js @@ -25,7 +25,10 @@ const TableOfContent = publicWidget.Widget.extend({ if (indexCallback >= 0) { extraMenuUpdateCallbacks.splice(indexCallback, 1); } - this._scrollingElement.scrollspy('dispose'); + const scrollSpyInstance = ScrollSpy.getInstance(this._scrollingElement); + if (scrollSpyInstance) { + scrollSpyInstance.dispose(); + } this.$el.css('top', ''); this.$el.find('.s_table_of_content_navbar').css('top', ''); this._super(...arguments); diff --git a/addons/website/static/tests/tours/snippet_table_of_content.js b/addons/website/static/tests/tours/snippet_table_of_content.js new file mode 100644 index 00000000000..2e9adb2bb43 --- /dev/null +++ b/addons/website/static/tests/tours/snippet_table_of_content.js @@ -0,0 +1,15 @@ +/** @odoo-module */ + +import wTourUtils from 'website.tour_utils'; + +wTourUtils.registerWebsitePreviewTour('snippet_table_of_content', { + test: true, + url: '/', + edition: true, +}, [ + wTourUtils.dragNDrop({id: 's_table_of_content', name: 'Table of Content'}), + wTourUtils.dragNDrop({id: 's_table_of_content', name: 'Table of Content'}), + // To make sure that the public widgets of the two previous ones started. + wTourUtils.dragNDrop({id: 's_banner', name: 'Banner'}), + ...wTourUtils.clickOnSave(), +]); diff --git a/addons/website/tests/test_snippets.py b/addons/website/tests/test_snippets.py index 3d8ce86189d..3c1228ed2b7 100644 --- a/addons/website/tests/test_snippets.py +++ b/addons/website/tests/test_snippets.py @@ -49,3 +49,6 @@ class TestSnippets(HttpCase): def test_07_image_gallery(self): self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_image_gallery', login='admin') + + def test_08_table_of_content(self): + self.start_tour(self.env['website'].get_client_action_url('/'), 'snippet_table_of_content', login='admin')