From 1644b9bc22b4b8e6fc6fdd510a1c3baba5f825fd Mon Sep 17 00:00:00 2001 From: Romeo Fragomeli Date: Fri, 18 Feb 2022 15:16:20 +0000 Subject: [PATCH] [REF] website, project: fix tour dropdown-menu click Remove jQuery usage as Bootstrap 5 don't relay on jQuery anymore, even if Bootstrap as a jQuery compatibility layer. From [1] > All the events for the dropdown are now triggered on the dropdown > toggle button and then bubbled up to the parent element. From [2] > events triggered with jQuery do not go through the native layer, so > if a handler has been bound natively, it won't be called. Note: [1] https://getbootstrap.com/docs/5.1/migration/#dropdowns [2] https://github.com/odoo/odoo/commit/a535d7c6fb5a6abe083e7d665d7243f5061a4773 Task ID: 2766483 Part-of: odoo/odoo#95450 --- addons/project/static/tests/tours/personal_stage_tour.js | 2 +- .../project/static/tests/tours/project_update_tour_tests.js | 4 ++-- addons/website/static/tests/tours/edit_megamenu.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/project/static/tests/tours/personal_stage_tour.js b/addons/project/static/tests/tours/personal_stage_tour.js index 134f40dcc63..d06553867ee 100644 --- a/addons/project/static/tests/tours/personal_stage_tour.js +++ b/addons/project/static/tests/tours/personal_stage_tour.js @@ -45,7 +45,7 @@ tour.register('personal_stage_tour', { content: 'Open column edit dropdown', trigger: '.o_kanban_header:eq(0)', run: function () { - $('.o_kanban_config.dropdown .dropdown-toggle').eq(0).click(); + document.querySelector('.o_kanban_config.dropdown .dropdown-toggle').dispatchEvent(new Event('click')); }, }, { content: "Try editing inbox", diff --git a/addons/project/static/tests/tours/project_update_tour_tests.js b/addons/project/static/tests/tours/project_update_tour_tests.js index c29ca199da9..4d854013ed2 100644 --- a/addons/project/static/tests/tours/project_update_tour_tests.js +++ b/addons/project/static/tests/tours/project_update_tour_tests.js @@ -81,9 +81,9 @@ tour.register('project_update_tour', { trigger: '.o_kanban_quick_create .o_kanban_add', extra_trigger: '.o_kanban_project_tasks' }, { - trigger: '.o_kanban_header:eq(1)', + trigger: '.o_kanban_group:nth-child(2) .o_kanban_header', run: function () { - $('.o_kanban_config.dropdown .dropdown-toggle').eq(1).click(); + document.querySelector('.o_kanban_group:nth-child(2) .o_kanban_config.dropdown .dropdown-toggle').dispatchEvent(new Event('click')) } }, { trigger: ".dropdown-item.o_column_edit", diff --git a/addons/website/static/tests/tours/edit_megamenu.js b/addons/website/static/tests/tours/edit_megamenu.js index 548eac6bd45..68619084932 100644 --- a/addons/website/static/tests/tours/edit_megamenu.js +++ b/addons/website/static/tests/tours/edit_megamenu.js @@ -10,7 +10,7 @@ const toggleMegaMenu = (stepOptions) => Object.assign({}, { // If the mega menu is displayed inside the extra menu items, it should // already be displayed. if (!this.$anchor[0].closest('.o_extra_menu_items')) { - this.$anchor[0].click(); + this.$anchor[0].dispatchEvent(new Event('click')) } }, }, stepOptions);