From a56e1ea1c803da3ef5a8007547b44412895f581b Mon Sep 17 00:00:00 2001 From: dise Date: Thu, 30 Nov 2023 10:10:02 +0000 Subject: [PATCH] [FIX] portal: change _search method to support custom search_in The _search method of the portal search panel uses the currently selected dropdown item to retrieve the search criteria ; however, when using a search criteria that is not displayed in the dropdown menu, the replace method causes a traceback, since calling attr on the empty jquery selector object returns undefined. The _search method was changed to use optional chaining before accessing the replace method, and to replace the search_in value by an empty string in case the result of the expression is undefined. closes odoo/odoo#146570 X-original-commit: 053176523ea97b1c7a2ce7cafa88c4bdf0b1795d Signed-off-by: Thibault Delavallee (tde) --- addons/portal/static/src/js/portal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/portal/static/src/js/portal.js b/addons/portal/static/src/js/portal.js index eabc7783bcb..e02e03a7b37 100644 --- a/addons/portal/static/src/js/portal.js +++ b/addons/portal/static/src/js/portal.js @@ -150,7 +150,7 @@ publicWidget.registry.portalSearchPanel = publicWidget.Widget.extend({ */ _search: function () { var search = new URL(window.location).searchParams; - search.set("search_in", this.$('.dropdown-item.active').attr('href').replace('#', '')); + search.set("search_in", this.$('.dropdown-item.active').attr('href')?.replace('#', '') || ""); search.set("search", this.$('input[name="search"]').val()); window.location.search = search.toString(); },