Skip to content

Commit 5943283

Browse files
committed
Fix #583
Filtering on visible elements only when traversing the menu. Fixes up/down keyboard navigation when traversing the menu and a filter is active. Some alignment changes in the source file.
1 parent fd78724 commit 5943283

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/jquery.multiselect.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,14 @@
288288
keypress: function(e) {
289289
switch(e.which) {
290290
case 27: // esc
291-
case 38: // up
292-
case 37: // left
291+
case 38: // up
292+
case 37: // left
293293
self.close();
294-
break;
294+
break;
295295
case 39: // right
296-
case 40: // down
296+
case 40: // down
297297
self.open();
298-
break;
298+
break;
299299
}
300300
},
301301
mouseenter: function() {
@@ -370,18 +370,18 @@
370370
e.preventDefault();
371371
switch(e.which) {
372372
case 9: // tab
373-
case 27: // esc
373+
case 27: // esc
374374
self.close();
375-
break;
375+
break;
376376
case 38: // up
377-
case 40: // down
378-
case 37: // left
379-
case 39: // right
377+
case 40: // down
378+
case 37: // left
379+
case 39: // right
380380
self._traverse(e.which, this);
381-
break;
381+
break;
382382
case 13: // enter
383383
$(this).find('input')[0].click();
384-
break;
384+
break;
385385
}
386386
})
387387
.delegate('input[type="checkbox"], input[type="radio"]', 'click.multiselect', function(e) {
@@ -496,20 +496,20 @@
496496
var moveToLast = which === 38 || which === 37;
497497

498498
// select the first li that isn't an optgroup label / disabled
499-
var $next = $start.parent()[moveToLast ? 'prevAll' : 'nextAll']('li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)').first();
499+
var $next = $start.parent()[moveToLast ? 'prevAll' : 'nextAll']('li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label):visible').first();
500500

501501
// if at the first/last element
502502
if(!$next.length) {
503503
var $container = this.menu.find('ul').last();
504504

505505
// move to the first/last
506-
this.menu.find('label')[ moveToLast ? 'last' : 'first' ]().trigger('mouseover');
506+
this.menu.find('label:visible')[ moveToLast ? 'last' : 'first' ]().trigger('mouseover');
507507

508508
// set scroll position
509509
$container.scrollTop(moveToLast ? $container.height() : 0);
510510

511511
} else {
512-
$next.find('label').trigger('mouseover');
512+
$next.find('label:visible').trigger('mouseover');
513513
}
514514
},
515515

0 commit comments

Comments
 (0)