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')