From c71af144a8ef8faefb2cf6846c32a8432d633430 Mon Sep 17 00:00:00 2001 From: Benjamin Vray <bvr@odoo.com> Date: Wed, 26 Jul 2023 07:45:45 +0000 Subject: [PATCH] [FIX] website: fix add menu item dialog traceback Steps to reproduce the bug: - Website application - Go to Website - Go to menu "Pages" - Click on "Edit Menu" - Click on "Add Menu Item" - Bug: This leads to a traceback. This bug was introduced by the commit [1], where we do a "querySelectorAll" on the anchor selector element, which doesn't actually exist in the "Add Menu Item" dialog. The code related to adding an anchor shouldn't be executed in this modal. This was changed in versions higher than 14, where we separated the code used in the "Add Menu Item" dialog from the code used for editing links in edit mode. In this commit, we fix this issue minimally by adding a "return" statement if the anchor selector element doesn't exist. [1]: https://github.com/odoo/odoo/commit/c9dbfd35ffda80f0ad07288f13ce9d0dde9591f2 opw-3422898 closes odoo/odoo#129710 Signed-off-by: Romain Derie (rde) <rde@odoo.com> --- addons/website/static/src/js/editor/widget_link.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/website/static/src/js/editor/widget_link.js b/addons/website/static/src/js/editor/widget_link.js index b3240059ff2b..c18e44550e30 100644 --- a/addons/website/static/src/js/editor/widget_link.js +++ b/addons/website/static/src/js/editor/widget_link.js @@ -46,6 +46,9 @@ weWidgets.LinkDialog.include({ _adaptPageAnchor: function () { var urlInputValue = this.$('input[name="url"]').val(); var $pageAnchor = this.$('.o_link_dialog_page_anchor'); + if (!$pageAnchor.length) { + return; + } var isFromWebsite = urlInputValue[0] === '/'; var $selectMenu = this.$('select[name="link_anchor"]'); var $anchorsLoading = this.$('.o_anchors_loading'); -- GitLab