Skip to content

Commit b330f86

Browse files
authored
Merge pull request #2477 from magento-tango/MAGETWO-86289
Fixed issues: - MAGETWO-86289 [2.2.x] Admin global search feature broken
2 parents 160dc85 + 306a77b commit b330f86

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function getWidgetInitOptions()
7373
'filterProperty' => 'name',
7474
'preventClickPropagation' => false,
7575
'minLength' => 2,
76+
'submitInputOnEnter' => false,
7677
]
7778
];
7879
}

app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Ui\DataProvider\AddFilterToCollectionInterface;
1212

1313
/**
14-
* Class AddFulltextFilterToCollection
14+
* Adds FullText search to Product Data Provider
1515
*/
1616
class AddFulltextFilterToCollection implements AddFilterToCollectionInterface
1717
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getSynonymsForPhrase($phrase)
8282
/**
8383
* Helper method to find the matching of $pattern to $synonymGroupsToExamine.
8484
* If matches, the particular array index is returned.
85-
* Otherwise false will be returned.
85+
* Otherwise null will be returned.
8686
*
8787
* @param string $pattern
8888
* @param array $synonymGroupsToExamine

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)