Skip to content

Commit 8c5f50b

Browse files
committed
Merge pull request #66 from algolia/cursorchanged-fired-on-hover
Ensure the cursorchanged event is also triggered on mouseover
2 parents d0ac6cb + 0705b3e commit 8c5f50b

8 files changed

+20
-29
lines changed

dist/autocomplete.angular.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@
15051505

15061506
_onSuggestionMouseEnter: function onSuggestionMouseEnter($e) {
15071507
this._removeCursor();
1508-
this._setCursor(DOM.element($e.currentTarget), true);
1508+
this._setCursor(DOM.element($e.currentTarget));
15091509
},
15101510

15111511
_onSuggestionMouseLeave: function onSuggestionMouseLeave() {
@@ -1548,12 +1548,10 @@
15481548
return this.$menu.find('.aa-cursor').first();
15491549
},
15501550

1551-
_setCursor: function setCursor($el, silent) {
1551+
_setCursor: function setCursor($el) {
15521552
$el.first().addClass('aa-cursor');
1553-
1554-
if (!silent) {
1555-
this.trigger('cursorMoved');
1556-
}
1553+
console.log('cursorMoved');
1554+
this.trigger('cursorMoved');
15571555
},
15581556

15591557
_removeCursor: function removeCursor() {

dist/autocomplete.angular.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/autocomplete.jquery.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@
15551555

15561556
_onSuggestionMouseEnter: function onSuggestionMouseEnter($e) {
15571557
this._removeCursor();
1558-
this._setCursor(DOM.element($e.currentTarget), true);
1558+
this._setCursor(DOM.element($e.currentTarget));
15591559
},
15601560

15611561
_onSuggestionMouseLeave: function onSuggestionMouseLeave() {
@@ -1598,12 +1598,10 @@
15981598
return this.$menu.find('.aa-cursor').first();
15991599
},
16001600

1601-
_setCursor: function setCursor($el, silent) {
1601+
_setCursor: function setCursor($el) {
16021602
$el.first().addClass('aa-cursor');
1603-
1604-
if (!silent) {
1605-
this.trigger('cursorMoved');
1606-
}
1603+
console.log('cursorMoved');
1604+
this.trigger('cursorMoved');
16071605
},
16081606

16091607
_removeCursor: function removeCursor() {

dist/autocomplete.jquery.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/autocomplete.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -2782,7 +2782,7 @@ return /******/ (function(modules) { // webpackBootstrap
27822782

27832783
_onSuggestionMouseEnter: function onSuggestionMouseEnter($e) {
27842784
this._removeCursor();
2785-
this._setCursor(DOM.element($e.currentTarget), true);
2785+
this._setCursor(DOM.element($e.currentTarget));
27862786
},
27872787

27882788
_onSuggestionMouseLeave: function onSuggestionMouseLeave() {
@@ -2825,12 +2825,10 @@ return /******/ (function(modules) { // webpackBootstrap
28252825
return this.$menu.find('.aa-cursor').first();
28262826
},
28272827

2828-
_setCursor: function setCursor($el, silent) {
2828+
_setCursor: function setCursor($el) {
28292829
$el.first().addClass('aa-cursor');
2830-
2831-
if (!silent) {
2832-
this.trigger('cursorMoved');
2833-
}
2830+
console.log('cursorMoved');
2831+
this.trigger('cursorMoved');
28342832
},
28352833

28362834
_removeCursor: function removeCursor() {

dist/autocomplete.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/autocomplete/dropdown.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ _.mixin(Dropdown.prototype, EventEmitter, {
7474

7575
_onSuggestionMouseEnter: function onSuggestionMouseEnter($e) {
7676
this._removeCursor();
77-
this._setCursor(DOM.element($e.currentTarget), true);
77+
this._setCursor(DOM.element($e.currentTarget));
7878
},
7979

8080
_onSuggestionMouseLeave: function onSuggestionMouseLeave() {
@@ -117,12 +117,9 @@ _.mixin(Dropdown.prototype, EventEmitter, {
117117
return this.$menu.find(_.className(this.cssClasses.prefix, this.cssClasses.cursor)).first();
118118
},
119119

120-
_setCursor: function setCursor($el, silent) {
120+
_setCursor: function setCursor($el) {
121121
$el.first().addClass(_.className(this.cssClasses.prefix, this.cssClasses.cursor, true));
122-
123-
if (!silent) {
124-
this.trigger('cursorMoved');
125-
}
122+
this.trigger('cursorMoved');
126123
},
127124

128125
_removeCursor: function removeCursor() {

test/unit/dropdown_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('Dropdown', function() {
9999
expect($suggestion).toHaveClass('aa-cursor');
100100
});
101101

102-
it('should not trigger cursorMoved', function() {
102+
it('should trigger cursorMoved', function() {
103103
var spy;
104104
var $suggestion;
105105

@@ -108,7 +108,7 @@ describe('Dropdown', function() {
108108
$suggestion = this.$menu.find('.aa-suggestion').first();
109109
$suggestion.mouseenter();
110110

111-
expect(spy).not.toHaveBeenCalled();
111+
expect(spy).toHaveBeenCalled();
112112
});
113113
});
114114

0 commit comments

Comments
 (0)