From eefdc1cdb6c21298e135fbbf986cabf742647caa Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Thu, 5 Oct 2017 16:15:21 +0200 Subject: [PATCH 1/2] Fixing keyboard submit of adminhtml suggest form. --- lib/web/mage/backend/suggest.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/web/mage/backend/suggest.js b/lib/web/mage/backend/suggest.js index 81bde35f9e12a..2ce3405783ea1 100644 --- a/lib/web/mage/backend/suggest.js +++ b/lib/web/mage/backend/suggest.js @@ -245,6 +245,20 @@ case keyCode.ENTER: case keyCode.NUMPAD_ENTER: + suggestList = event.currentTarget.parentNode.getElementsByTagName('ul')[0]; + hasSelectedItems = suggestList.getElementsByClassName('_active').length >= 0; + + if (hasSelectedItems) { + selectedItem = $(suggestList.getElementsByClassName('_active')[0]); + /* eslint-disable max-depth */ + if (selectedItem.find('a') && selectedItem.find('a').attr('href') !== undefined) { + window.location = selectedItem.find('a').attr('href'); + event.preventDefault(); + + return false; + } + /* eslint-enable max-depth */ + } if (this.isDropdownShown() && this._focused) { this._proxyEvents(event); From 00afa44ab1d21cf3a66d07f9e365a3d64ca4fe85 Mon Sep 17 00:00:00 2001 From: Romain Ruaud Date: Mon, 23 Oct 2017 11:41:22 +0200 Subject: [PATCH 2/2] Fixing keyboard submit of adminhtml suggest form. --- lib/web/mage/backend/suggest.js | 39 +++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/web/mage/backend/suggest.js b/lib/web/mage/backend/suggest.js index 2ce3405783ea1..412a80804ae0f 100644 --- a/lib/web/mage/backend/suggest.js +++ b/lib/web/mage/backend/suggest.js @@ -245,20 +245,7 @@ case keyCode.ENTER: case keyCode.NUMPAD_ENTER: - suggestList = event.currentTarget.parentNode.getElementsByTagName('ul')[0]; - hasSelectedItems = suggestList.getElementsByClassName('_active').length >= 0; - - if (hasSelectedItems) { - selectedItem = $(suggestList.getElementsByClassName('_active')[0]); - /* eslint-disable max-depth */ - if (selectedItem.find('a') && selectedItem.find('a').attr('href') !== undefined) { - window.location = selectedItem.find('a').attr('href'); - event.preventDefault(); - - return false; - } - /* eslint-enable max-depth */ - } + this._toggleEnter(event); if (this.isDropdownShown() && this._focused) { this._proxyEvents(event); @@ -328,6 +315,30 @@ this._bindDropdown(); }, + /** + * @param {Object} event - event object + * @private + */ + _toggleEnter: function (event) { + var suggestList, + activeItems, + selectedItem; + + suggestList = $(event.currentTarget.parentNode).find('ul').first(); + activeItems = suggestList.find('._active'); + + if (activeItems.length >= 0) { + selectedItem = activeItems.first(); + + if (selectedItem.find('a') && selectedItem.find('a').attr('href') !== undefined) { + window.location = selectedItem.find('a').attr('href'); + event.preventDefault(); + + return false; + } + } + }, + /** * @param {Object} e - event object * @private