[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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user