summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorLaurent Stukkens (LTU) <ltu@odoo.com>2020-05-29 09:21:25 +0000
committerLaurent Stukkens (LTU) <ltu@odoo.com>2020-05-29 11:16:08 +0000
commit0ce05c540d25ebc4bd589c1e2436ee2aa642ccf5 (patch)
tree0e1499b321bd1260504caf16124882cc11da061c /addons
parent6c05781d985fdf249f84bde4ad662758a65304f8 (diff)
[FIX] website_sale: prevent search bar bug
Issue When pressing UP or DOWN arrow in search bar with empty text a traceback occurs. Step to Reproduce - Install website_sale "eCommerce" application - Go to Website - Go to Shop - Click in Search Bar - Press Up or Down Key Cause When no text is entered in the search bar, the $menu is undefined so trying to access children causes the error Solution Test that $menu is defined prior to try accessing its children task id-2252923 closes odoo/odoo#52161 Forward-port-of: #51920 X-original-commit: 30785e68852fa3cd18be11fcbaad4e886d01301c Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/website_sale/static/src/snippets/s_products_searchbar/000.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/website_sale/static/src/snippets/s_products_searchbar/000.js b/addons/website_sale/static/src/snippets/s_products_searchbar/000.js
index 5117d405a05..2aaafca20b6 100644
--- a/addons/website_sale/static/src/snippets/s_products_searchbar/000.js
+++ b/addons/website_sale/static/src/snippets/s_products_searchbar/000.js
@@ -123,12 +123,12 @@ publicWidget.registry.productsSearchBar = publicWidget.Widget.extend({
this._render();
break;
case $.ui.keyCode.UP:
- ev.preventDefault();
- this.$menu.children().last().focus();
- break;
case $.ui.keyCode.DOWN:
ev.preventDefault();
- this.$menu.children().first().focus();
+ if (this.$menu) {
+ let $element = ev.which === $.ui.keyCode.UP ? this.$menu.children().last() : this.$menu.children().first();
+ $element.focus();
+ }
break;
}
},