Skip to content

Commit bd47df7

Browse files
author
Dragan Atanasov
committed
Fixed TypeError: this._getFirstVisibleElement(...).addClass when search term does not exist on pressing Home or End button #14274
1 parent 068a97e commit bd47df7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/code/Magento/Search/view/frontend/web/form-mini.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,17 @@ define([
206206

207207
switch (keyCode) {
208208
case $.ui.keyCode.HOME:
209-
this._getFirstVisibleElement().addClass(this.options.selectClass);
210-
this.responseList.selected = this._getFirstVisibleElement();
209+
if(this._getFirstVisibleElement()) {
210+
this._getFirstVisibleElement().addClass(this.options.selectClass);
211+
this.responseList.selected = this._getFirstVisibleElement();
212+
}
211213
break;
212214

213215
case $.ui.keyCode.END:
214-
this._getLastElement().addClass(this.options.selectClass);
215-
this.responseList.selected = this._getLastElement();
216+
if(this._getFirstVisibleElement()) {
217+
this._getLastElement().addClass(this.options.selectClass);
218+
this.responseList.selected = this._getLastElement();
219+
}
216220
break;
217221

218222
case $.ui.keyCode.ESCAPE:

0 commit comments

Comments
 (0)