summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome/menu.js
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-03-19 14:18:55 +0100
committerAlexandre Kühn <aku@odoo.com>2018-03-19 15:17:56 +0100
commit71616e8d4f9a5bf92487dc6cc89d4945d29b4343 (patch)
treeddd27ccfc4e8b6f3aed7436210c44c6b7e5f55fc /addons/web/static/src/js/chrome/menu.js
parente2dd31cd7bb51f3908c8737f6d474312afa948f4 (diff)
[FIX] web: pick correct menu item on hashchange
Before this commit, we had the following issue: 1. install CRM and Sales 2. Sales > Customers > (open any form) 3. Click on browser's "back" button We are redirected to the contact kanban view in CRM instead of Sales. This is due to the fact that both menu items share the same action. When the user uses the browser's "back" button (AKA. it triggers an hashchange event), the web_client opens the first menu_item that matches the action. This commit fixes the issue by allowing us to open an action by providing a menu ID: 1. If it matches the action, then it opens this menu instead of the first match. 2. If we do not provide any menuID, or this menuID does not match with the action, it falls back to the first menu matching this action. Fixes #23639
Diffstat (limited to 'addons/web/static/src/js/chrome/menu.js')
-rw-r--r--addons/web/static/src/js/chrome/menu.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/addons/web/static/src/js/chrome/menu.js b/addons/web/static/src/js/chrome/menu.js
index c9d58d89c81..35e57f1c562 100644
--- a/addons/web/static/src/js/chrome/menu.js
+++ b/addons/web/static/src/js/chrome/menu.js
@@ -145,15 +145,22 @@ var Menu = Widget.extend({
});
},
/**
- * Call open_menu with the first menu_item matching an action_id
+ * Call open_menu on a menu_item that matches the action_id
+ *
+ * If `menuID` is a match on this action, open this menu_item.
+ * Otherwise open the first menu_item that matches the action_id.
*
* @param {Number} id the action_id to match
+ * @param {Number} [menuID] a menu ID that may match with provided action
*/
- open_action: function (id) {
+ open_action: function (id, menuID) {
var $menu = this.$el.add(this.$secondary_menus).find('a[data-action-id="' + id + '"]');
- var menu_id = $menu.data('menu');
- if (menu_id) {
- this.open_menu(menu_id);
+ if (!(menuID && $menu.filter("[data-menu='" + menuID + "']").length)) {
+ // menuID doesn't match action, so pick first menu_item
+ menuID = $menu.data('menu');
+ }
+ if (menuID) {
+ this.open_menu(menuID);
}
},
/**