Skip to content

Commit 4d2880e

Browse files
ENGCOM-1057: Fixed TypeError when search term does not exist on pressing Home or End button #14274 #14301
- Merge Pull Request #14301 from drashmk/magento2:14274-quick-search - Merged commits: 1. bd47df7 2. 98be34b 3. a5252de
2 parents cec4bf4 + a5252de commit 4d2880e

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._getLastElement()) {
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)