From 21f1a593a1fed08053918a31ff9f6d239df2dbca Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Thu, 5 Jul 2018 11:27:27 +0200 Subject: [PATCH] [FIX] website: new content links not triggered Clicking outside the new content options should close the overlay. Every options are triggering a JS event (mostly opening a modal) that works fine. But the 'New Job offer' options is simply a href link which is not going through anymore since there was a call to `preventDefault`. opw-1860196 --- addons/website/static/src/js/menu/new_content.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/menu/new_content.js b/addons/website/static/src/js/menu/new_content.js index f2d02534f68..c577858f3eb 100644 --- a/addons/website/static/src/js/menu/new_content.js +++ b/addons/website/static/src/js/menu/new_content.js @@ -14,7 +14,8 @@ var NewContentMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ new_page: '_createNewPage', }), events: _.extend({}, websiteNavbarData.WebsiteNavbarActionWidget.prototype.events || {}, { - 'click > a, #o_new_content_menu_choices': '_onMenuToggleClick', + 'click > a': '_onMenuToggleClick', + 'click > #o_new_content_menu_choices': '_onBackgroundClick', }), /** @@ -65,7 +66,6 @@ var NewContentMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ /** * Called when the menu's toggle button is clicked -> Opens the menu. - * Or when there is a click outside the menu's options -> Closes the menu * * @private * @param {Event} ev @@ -74,6 +74,15 @@ var NewContentMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ ev.preventDefault(); this.$newContentMenuChoices.toggleClass('o_hidden'); }, + /** + * Called when a click outside the menu's options occurs -> Closes the menu + * + * @private + * @param {Event} ev + */ + _onBackgroundClick: function (ev) { + this.$newContentMenuChoices.addClass('o_hidden'); + }, }); websiteNavbarData.websiteNavbarRegistry.add(NewContentMenu, '.o_new_content_menu');