isSuggestionsAllowed()):?>
- data-mage-init='{"quickSearch":{
- "formSelector":"#search_mini_form",
- "url":"= $block->escapeUrl($helper->getSuggestUrl())?>",
- "destinationSelector":"#search_autocomplete",
- "minSearchLength":"= $block->escapeHtml($helper->getMinQueryLength()) ?>"}
- }'
-
+ data-mage-init='{
+ "quickSearch": {
+ "formSelector": "#search_mini_form",
+ "url": "= /* @noEscape */ $quickSearchUrl ?>",
+ "destinationSelector": "#search_autocomplete",
+ "minSearchLength": "= $escaper->escapeHtml($helper->getMinQueryLength()) ?>"
+ }
+ }'
type="text"
- name="= $block->escapeHtmlAttr($helper->getQueryParamName()) ?>"
+ name="= $escaper->escapeHtmlAttr($helper->getQueryParamName()) ?>"
value="= /* @noEscape */ $helper->getEscapedQueryText() ?>"
- placeholder="= $block->escapeHtmlAttr(__('Search entire store here...')) ?>"
+ placeholder="= $escaper->escapeHtmlAttr(__('Search entire store here...')) ?>"
class="input-text"
- maxlength="= $block->escapeHtmlAttr($helper->getMaxQueryLength()) ?>"
+ maxlength="= $escaper->escapeHtmlAttr($helper->getMaxQueryLength()) ?>"
role="combobox"
aria-haspopup="false"
aria-autocomplete="both"
@@ -49,11 +51,11 @@ $configProvider = $block->getData('configProvider');
diff --git a/vendor/magento/module-search/view/frontend/web/js/form-mini.js b/vendor/magento/module-search/view/frontend/web/js/form-mini.js
index b4493c5f380..605c2fbbf9b 100644
--- a/vendor/magento/module-search/view/frontend/web/js/form-mini.js
+++ b/vendor/magento/module-search/view/frontend/web/js/form-mini.js
@@ -35,12 +35,12 @@ define([
selectClass: 'selected',
template:
'
' +
- '' +
- ' <%- data.title %>' +
- '' +
- '' +
- '<%- data.num_results %>' +
- '' +
+ '' +
+ ' <%- data.title %>' +
+ '' +
+ '' +
+ '<%- data.num_results %>' +
+ '' +
'',
submitBtn: 'button[type="submit"]',
searchLabel: '[data-role=minisearch-label]',
@@ -297,60 +297,64 @@ define([
this.submitBtn.disabled = isEmpty(value);
if (value.length >= parseInt(this.options.minSearchLength, 10)) {
- $.getJSON(this.options.url, {
- q: value
- }, $.proxy(function (data) {
- if (data.length) {
- $.each(data, function (index, element) {
- var html;
-
- element.index = index;
- html = template({
- data: element
+ this.submitBtn.disabled = false;
+
+ if (this.options.url !== '') { //eslint-disable-line eqeqeq
+ $.getJSON(this.options.url, {
+ q: value
+ }, $.proxy(function (data) {
+ if (data.length) {
+ $.each(data, function (index, element) {
+ var html;
+
+ element.index = index;
+ html = template({
+ data: element
+ });
+ dropdown.append(html);
});
- dropdown.append(html);
- });
- this._resetResponseList(true);
-
- this.responseList.indexList = this.autoComplete.html(dropdown)
- .css(clonePosition)
- .show()
- .find(this.options.responseFieldElements + ':visible');
-
- this.element.removeAttr('aria-activedescendant');
-
- if (this.responseList.indexList.length) {
- this._updateAriaHasPopup(true);
+ this._resetResponseList(true);
+
+ this.responseList.indexList = this.autoComplete.html(dropdown)
+ .css(clonePosition)
+ .show()
+ .find(this.options.responseFieldElements + ':visible');
+
+ this.element.removeAttr('aria-activedescendant');
+
+ if (this.responseList.indexList.length) {
+ this._updateAriaHasPopup(true);
+ } else {
+ this._updateAriaHasPopup(false);
+ }
+
+ this.responseList.indexList
+ .on('click', function (e) {
+ this.responseList.selected = $(e.currentTarget);
+ this.searchForm.trigger('submit');
+ }.bind(this))
+ .on('mouseenter mouseleave', function (e) {
+ this.responseList.indexList.removeClass(this.options.selectClass);
+ $(e.target).addClass(this.options.selectClass);
+ this.responseList.selected = $(e.target);
+ this.element.attr('aria-activedescendant', $(e.target).attr('id'));
+ }.bind(this))
+ .on('mouseout', function (e) {
+ if (!this._getLastElement() &&
+ this._getLastElement().hasClass(this.options.selectClass)) {
+ $(e.target).removeClass(this.options.selectClass);
+ this._resetResponseList(false);
+ }
+ }.bind(this));
} else {
+ this._resetResponseList(true);
+ this.autoComplete.hide();
this._updateAriaHasPopup(false);
+ this.element.removeAttr('aria-activedescendant');
}
-
- this.responseList.indexList
- .on('click', function (e) {
- this.responseList.selected = $(e.currentTarget);
- this.searchForm.trigger('submit');
- }.bind(this))
- .on('mouseenter mouseleave', function (e) {
- this.responseList.indexList.removeClass(this.options.selectClass);
- $(e.target).addClass(this.options.selectClass);
- this.responseList.selected = $(e.target);
- this.element.attr('aria-activedescendant', $(e.target).attr('id'));
- }.bind(this))
- .on('mouseout', function (e) {
- if (!this._getLastElement() &&
- this._getLastElement().hasClass(this.options.selectClass)) {
- $(e.target).removeClass(this.options.selectClass);
- this._resetResponseList(false);
- }
- }.bind(this));
- } else {
- this._resetResponseList(true);
- this.autoComplete.hide();
- this._updateAriaHasPopup(false);
- this.element.removeAttr('aria-activedescendant');
- }
- }, this));
+ }, this));
+ }
} else {
this._resetResponseList(true);
this.autoComplete.hide();