Skip to content

Commit d6886c1

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-92133' into 2.3-develop-pr22
2 parents bb039a6 + 55a6d51 commit d6886c1

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

app/code/Magento/Backend/Block/GlobalSearch.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function getWidgetInitOptions()
3131
'filterProperty' => 'name',
3232
'preventClickPropagation' => false,
3333
'minLength' => 2,
34+
'submitInputOnEnter' => false,
3435
]
3536
];
3637
}

app/code/Magento/Search/Model/SynonymAnalyzer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getSynonymsForPhrase($phrase)
8383
/**
8484
* Helper method to find the matching of $pattern to $synonymGroupsToExamine.
8585
* If matches, the particular array index is returned.
86-
* Otherwise false will be returned.
86+
* Otherwise null will be returned.
8787
*
8888
* @param string $pattern
8989
* @param array $synonymGroupsToExamine
@@ -99,6 +99,7 @@ private function findInArray(string $pattern, array $synonymGroupsToExamine)
9999
}
100100
$position++;
101101
}
102+
102103
return null;
103104
}
104105

lib/web/mage/backend/suggest.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
inputWrapper: '<div class="mage-suggest"><div class="mage-suggest-inner"></div></div>',
6666
dropdownWrapper: '<div class="mage-suggest-dropdown"></div>',
6767
preventClickPropagation: true,
68-
currentlySelected: null
68+
currentlySelected: null,
69+
submitInputOnEnter: true
6970
},
7071

7172
/**
@@ -79,7 +80,6 @@
7980
label: ''
8081
};
8182
this.templates = {};
82-
8383
this._renderedContext = null;
8484
this._selectedItem = this._nonSelectedItem;
8585
this._control = this.options.controls || {};
@@ -312,18 +312,23 @@
312312
click: this.search
313313
}, this.options.events));
314314

315+
this._bindSubmit();
315316
this._bindDropdown();
316317
},
317318

318319
/**
319-
* @param {Object} event - event object
320+
* @param {Object} event
320321
* @private
321322
*/
322323
_toggleEnter: function (event) {
323324
var suggestList,
324325
activeItems,
325326
selectedItem;
326327

328+
if (!this.options.submitInputOnEnter) {
329+
event.preventDefault();
330+
}
331+
327332
suggestList = $(event.currentTarget.parentNode).find('ul').first();
328333
activeItems = suggestList.find('._active');
329334

@@ -333,12 +338,22 @@
333338
if (selectedItem.find('a') && selectedItem.find('a').attr('href') !== undefined) {
334339
window.location = selectedItem.find('a').attr('href');
335340
event.preventDefault();
336-
337-
return false;
338341
}
339342
}
340343
},
341344

345+
/**
346+
* Bind handlers for submit on enter
347+
* @private
348+
*/
349+
_bindSubmit: function () {
350+
this.element.parents('form').on('submit', function (event) {
351+
if (!this.submitInputOnEnter) {
352+
event.preventDefault();
353+
}
354+
});
355+
},
356+
342357
/**
343358
* @param {Object} e - event object
344359
* @private
@@ -465,8 +480,8 @@
465480
}
466481

467482
if (this._trigger('beforeselect', e || null, {
468-
item: this._focused
469-
}) === false) {
483+
item: this._focused
484+
}) === false) {
470485
return;
471486
}
472487
this._selectItem(e);
@@ -701,9 +716,6 @@
701716
if ($.isArray(o.source)) {
702717
response(this.filter(o.source, term));
703718
} else if ($.type(o.source) === 'string') {
704-
if (this._xhr) {
705-
this._xhr.abort();
706-
}
707719
ajaxData = {};
708720
ajaxData[this.options.termAjaxArgument] = term;
709721

@@ -729,10 +741,6 @@
729741
_abortSearch: function () {
730742
this.element.removeClass(this.options.loadingClass);
731743
clearTimeout(this._searchTimeout);
732-
733-
if (this._xhr) {
734-
this._xhr.abort();
735-
}
736744
},
737745

738746
/**
@@ -905,8 +913,8 @@
905913
'<li class="mage-suggest-search-field" data-role="parent-choice-element"><' +
906914
'label class="mage-suggest-search-label"></label></li></ul>',
907915
choiceTemplate: '<li class="mage-suggest-choice button"><div><%- text %></div>' +
908-
'<span class="mage-suggest-choice-close" tabindex="-1" ' +
909-
'data-mage-init=\'{"actionLink":{"event":"removeOption"}}\'></span></li>',
916+
'<span class="mage-suggest-choice-close" tabindex="-1" ' +
917+
'data-mage-init=\'{"actionLink":{"event":"removeOption"}}\'></span></li>',
910918
selectedClass: 'mage-suggest-selected'
911919
},
912920

0 commit comments

Comments
 (0)