Skip to content

Commit 785f461

Browse files
author
Volodymyr Zaets
committed
Merge remote-tracking branch 'origin/MAGETWO-44647' into PR
2 parents 7191937 + f85d462 commit 785f461

File tree

2 files changed

+46
-17
lines changed

2 files changed

+46
-17
lines changed

app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ define([
77
'underscore',
88
'./abstract',
99
'Magento_Ui/js/lib/key-codes',
10-
'mage/translate'
11-
], function (_, Abstract, keyCodes, $t) {
10+
'mage/translate',
11+
'jquery'
12+
], function (_, Abstract, keyCodes, $t, $) {
1213
'use strict';
1314

1415
/**
@@ -239,9 +240,7 @@ define([
239240
},
240241

241242
/**
242-
* get filtered value
243-
*
244-
* @returns {Array} filtered array
243+
* Get filtered value*
245244
*/
246245
getValue: function () {
247246
var options = this.options(),
@@ -255,7 +254,7 @@ define([
255254
},
256255

257256
/**
258-
* get selected element labels
257+
* Get selected element labels
259258
*
260259
* @returns {Array} array labels
261260
*/
@@ -301,16 +300,45 @@ define([
301300
*
302301
* @param {Object} data - object with data about this element
303302
* @param {Number} index - element index
303+
* @param {Object} event - mousemove event
304+
*/
305+
306+
onMousemove: function (data, index, event) {
307+
var target = $(event.target),
308+
id;
309+
310+
if (this.isCursorPositionChange(event)) {
311+
return false;
312+
}
313+
314+
target.is('li') ? id = target.index() : id = target.parent('li').index();
315+
id !== this.hoverElIndex() ? this.hoverElIndex(id) : false;
316+
317+
this.setCursorPosition(event);
318+
},
319+
320+
/**
321+
* Set X and Y cursor position
322+
*
323+
* @param {Object} event - mousemove event
304324
*/
305-
onHoveredIn: function (data, index) {
306-
this.hoverElIndex(index);
325+
setCursorPosition: function (event) {
326+
this.cursorPosition = {
327+
x: event.pageX,
328+
y: event.pageY
329+
};
307330
},
308331

309332
/**
310-
* Remove hover to some list element and write element ID from variable
333+
* Check previous and current cursor position
334+
*
335+
* @param {Object} event - mousemove event
336+
* @returns {Boolean}
311337
*/
312-
onHoveredOut: function () {
313-
this.hoverElIndex(null);
338+
isCursorPositionChange: function (event) {
339+
return this.cursorPosition &&
340+
this.cursorPosition.x === event.pageX &&
341+
this.cursorPosition.y === event.pageY;
314342
},
315343

316344
/**
@@ -394,7 +422,7 @@ define([
394422
var keyName = keyCodes[event.keyCode];
395423

396424
if (this.isTabKey(event)) {
397-
if (!this.filterOptionsFocus() && this.listVisible() && this.filterOptions ) {
425+
if (!this.filterOptionsFocus() && this.listVisible() && this.filterOptions) {
398426
this.cacheUiSelect.blur();
399427
this.filterOptionsFocus(true);
400428
this.cleanHoveredElement();

app/code/Magento/Ui/view/base/web/templates/grid/filters/elements/ui-select.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@
8888
</label>
8989
</div>
9090
<!-- /ko -->
91-
<ul class="admin__action-multiselect-menu-inner">
91+
<ul class="admin__action-multiselect-menu-inner"
92+
data-bind="
93+
event: {
94+
mousemove: function(){onMousemove($data, $index(), event)}
95+
}
96+
">
9297
<!-- ko foreach: { data: options, as: 'option'} -->
9398
<li
9499
class="action-menu-item"
@@ -97,10 +102,6 @@
97102
_selected: $parent.isSelected(option.value),
98103
_hover: $parent.isHovered($index(), $element)
99104
},
100-
event: {
101-
mouseenter: function(){$parent.onHoveredIn($data, $index())},
102-
mouseleave: function(){$parent.onHoveredOut($data, $index())},
103-
},
104105
click: $parent.toggleOptionSelected.bind($parent, $data, $index())">
105106
<input
106107
class="admin__control-checkbox"

0 commit comments

Comments
 (0)