Skip to content

Commit fcbcf38

Browse files
SteveTheTechiemlh758
authored andcommitted
Fix #770 - Scroll on Focus w/ _traverse() (#776)
Fix #770 - Scroll on Focus w/ _traverse()
1 parent 195ad46 commit fcbcf38

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/jquery.multiselect.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@
729729
this.classList.remove('ui-state-hover');
730730
})
731731
// option label
732-
.on('mouseenter.multiselect', 'label', function() {
732+
.on('mouseenter.multiselect', 'label', function(e, param) {
733733
if (!this.classList.contains('ui-state-disabled')) {
734734
var checkboxes = self.$checkboxes[0];
735735
var scrollLeft = checkboxes.scrollLeft;
@@ -741,9 +741,11 @@
741741
$(this).addClass('ui-state-hover').find('input').focus();
742742

743743
// Restore scroll positions if altered by setting input focus
744-
checkboxes.scrollLeft = scrollLeft;
745-
checkboxes.scrollTop = scrollTop;
746-
window.scrollTo(scrollX, scrollY);
744+
if ( !param || !param.allowScroll ) {
745+
checkboxes.scrollLeft = scrollLeft;
746+
checkboxes.scrollTop = scrollTop;
747+
window.scrollTo(scrollX, scrollY);
748+
}
747749
}
748750
})
749751
// Keyboard navigation of the menu
@@ -1231,13 +1233,13 @@
12311233
var $container = this.$menu.find('ul').last();
12321234

12331235
// move to the first/last
1234-
this.$menu.find('label').filter(':visible')[ moveToLast ? 'last' : 'first' ]().trigger('mouseover');
1236+
this.$menu.find('label').filter(':visible')[ moveToLast ? 'last' : 'first' ]().trigger('mouseover', {allowScroll: true});
12351237

12361238
// set scroll position
12371239
$container.scrollTop(moveToLast ? $container.height() : 0);
12381240
}
12391241
else {
1240-
$next.find('label').filter(':visible')[ moveToLast ? "last" : "first" ]().trigger('mouseover');
1242+
$next.find('label').filter(':visible')[ moveToLast ? "last" : "first" ]().trigger('mouseover', {allowScroll: true});
12411243
}
12421244
},
12431245

0 commit comments

Comments
 (0)