[FIX] website: fix snippet handler for BS5 scroll spy (at destroy event)
This commit correclty destroy the component by removing handler and callback. This fix some issues in tests. Task ID: 2766483 Part-of: odoo/odoo#95450
This commit is contained in:
@@ -14,12 +14,18 @@ const TableOfContent = publicWidget.Widget.extend({
|
||||
async start() {
|
||||
await this._super(...arguments);
|
||||
this._updateTableOfContentNavbarPosition();
|
||||
extraMenuUpdateCallbacks.push(this._updateTableOfContentNavbarPosition.bind(this));
|
||||
this._updateTableOfContentNavbarPositionBound = this._updateTableOfContentNavbarPosition.bind(this);
|
||||
extraMenuUpdateCallbacks.push(this._updateTableOfContentNavbarPositionBound);
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
destroy() {
|
||||
const indexCallback = extraMenuUpdateCallbacks.indexOf(this._updateTableOfContentNavbarPositionBound);
|
||||
if (indexCallback >= 0) {
|
||||
extraMenuUpdateCallbacks.splice(indexCallback, 1);
|
||||
}
|
||||
this._scrollingElement.scrollspy('dispose');
|
||||
this.$target.css('top', '');
|
||||
this.$target.find('.s_table_of_content_navbar').css('top', '');
|
||||
this._super(...arguments);
|
||||
@@ -42,7 +48,8 @@ const TableOfContent = publicWidget.Widget.extend({
|
||||
const $mainNavBar = $('#oe_main_menu_navbar');
|
||||
position += $mainNavBar.length ? $mainNavBar.outerHeight() : 0;
|
||||
position += isHorizontalNavbar ? this.$target.outerHeight() : 0;
|
||||
$().getScrollingElement().scrollspy({target: '.s_table_of_content_navbar', method: 'offset', offset: position + 100, alwaysKeepFirstActive: true});
|
||||
this._scrollingElement = $().getScrollingElement();
|
||||
this._scrollingElement.scrollspy({target: this.$target.find('.s_table_of_content_navbar'), method: 'offset', offset: position + 100, alwaysKeepFirstActive: true});
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user