diff --git a/addons/board/static/tests/dashboard_tests.js b/addons/board/static/tests/dashboard_tests.js index 588690463e9..52815921499 100644 --- a/addons/board/static/tests/dashboard_tests.js +++ b/addons/board/static/tests/dashboard_tests.js @@ -5,6 +5,7 @@ var BoardView = require('board.BoardView'); var ListController = require('web.ListController'); var testUtils = require('web.test_utils'); +var testUtilsDom = require('web.test_utils_dom'); var ListRenderer = require('web.ListRenderer'); var pyUtils = require('web.py_utils'); @@ -740,18 +741,33 @@ QUnit.test('save two searches to dashboard', function (assert) { $('.o_searchview_extended_prop_value .o_input').val('a') $('.o_apply_filter').click(); // Add it to dashboard - $('.o_add_to_dashboard_button').click(); + testUtilsDom.click($('.o_search_options button:contains(Favorites)')); + $('.o_search_options .dropdown-menu.o_favorites_menu').one('click', function (ev) { + // This handler is on the webClient + // But since the test suite doesn't have one + // We manually set it here + ev.stopPropagation(); + }); + testUtilsDom.click($('.o_search_options .o_add_to_dashboard_link')); + testUtilsDom.click($('.o_add_to_dashboard_button')); // Remove it $('.o_facet_remove').click(); // Add the second filter $('span.fa-filter').click(); - $('span.fa-filter').click(); $('.o_add_custom_filter:visible').click(); $('.o_searchview_extended_prop_value .o_input').val('b') $('.o_apply_filter').click(); // Add it to dashboard - $('.o_add_to_dashboard_button').click(); + testUtilsDom.click($('.o_search_options button:contains(Favorites)')); + $('.o_search_options .dropdown-menu.o_favorites_menu').one('click', function (ev) { + // This handler is on the webClient + // But since the test suite doesn't have one + // We manually set it here + ev.stopPropagation(); + }); + testUtilsDom.click($('.o_search_options .o_add_to_dashboard_link')); + testUtilsDom.click($('.o_add_to_dashboard_button')); actionManager.destroy(); }); diff --git a/addons/web/static/src/js/chrome/abstract_web_client.js b/addons/web/static/src/js/chrome/abstract_web_client.js index 7a67d29614f..542b2ebf2b8 100644 --- a/addons/web/static/src/js/chrome/abstract_web_client.js +++ b/addons/web/static/src/js/chrome/abstract_web_client.js @@ -31,7 +31,9 @@ var qweb = core.qweb; var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMixin, { dependencies: ['notification'], - events: _.extend(KeyboardNavigationMixin.events, {}), + events: _.extend({}, KeyboardNavigationMixin.events, { + 'click .o_search_options .dropdown-menu': '_onClickDropDownMenu', + }), custom_events: { clear_uncommitted_changes: function (e) { this.clear_uncommitted_changes().then(e.data.callback); @@ -331,6 +333,16 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi // Handlers //-------------------------------------------------------------------------- + /** + * When clicking inside a dropdown to modify search options + * prevents the bootstrap dropdown to close on itself + * + * @private + * @param {Event} ev + */ + _onClickDropDownMenu: function (ev) { + ev.stopPropagation(); + }, /** * Whenever the connection is lost, we need to notify the user. * diff --git a/addons/web/static/src/js/chrome/control_panel.js b/addons/web/static/src/js/chrome/control_panel.js index 5d0601820d0..07a6c3bcd70 100644 --- a/addons/web/static/src/js/chrome/control_panel.js +++ b/addons/web/static/src/js/chrome/control_panel.js @@ -100,11 +100,6 @@ var ControlPanel = Widget.extend({ $switch_buttons: this.$('.o_cp_switch_buttons'), }; - // Prevent the search dropdowns to close when clicking inside them - this.$el.on('click.bs.dropdown', '.o_search_options .dropdown-menu', function (e) { - e.stopPropagation(); - }); - // By default, hide the ControlPanel and remove its contents from the DOM this._toggle_visibility(false); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 223a7b7785c..f286e81e597 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1359,16 +1359,17 @@