Skip to content

Commit e519c34

Browse files
committed
fixed: disabled Selectmenu receives focus on tab, thx to gcko, see fnagel#136
1 parent 0852cea commit e519c34

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

ui/jquery.ui.selectmenu.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -573,25 +573,28 @@ $.widget("ui.selectmenu", {
573573
},
574574

575575
_moveSelection: function(amt, recIndex) {
576-
var currIndex = parseInt(this._selectedOptionLi().data('index') || 0, 10);
577-
var newIndex = currIndex + amt;
578-
// do not loop when using up key
576+
// do nothing if disabled
577+
if (!this.options.disabled) {
578+
var currIndex = parseInt(this._selectedOptionLi().data('index') || 0, 10);
579+
var newIndex = currIndex + amt;
580+
// do not loop when using up key
579581

580-
if (newIndex < 0) {
581-
newIndex = 0;
582-
}
583-
if (newIndex > this._optionLis.size() - 1) {
584-
newIndex = this._optionLis.size() - 1;
585-
}
586-
//Occurs when a full loop has been made
587-
if (newIndex === recIndex) { return false; }
582+
if (newIndex < 0) {
583+
newIndex = 0;
584+
}
585+
if (newIndex > this._optionLis.size() - 1) {
586+
newIndex = this._optionLis.size() - 1;
587+
}
588+
// Occurs when a full loop has been made
589+
if (newIndex === recIndex) { return false; }
588590

589-
if (this._optionLis.eq(newIndex).hasClass( this.namespace + '-state-disabled' )) {
590-
// if option at newIndex is disabled, call _moveFocus, incrementing amt by one
591-
(amt > 0) ? ++amt : --amt;
592-
this._moveSelection(amt, newIndex);
593-
} else {
594-
return this._optionLis.eq(newIndex).trigger('mouseup');
591+
if (this._optionLis.eq(newIndex).hasClass( this.namespace + '-state-disabled' )) {
592+
// if option at newIndex is disabled, call _moveFocus, incrementing amt by one
593+
(amt > 0) ? ++amt : --amt;
594+
this._moveSelection(amt, newIndex);
595+
} else {
596+
return this._optionLis.eq(newIndex).trigger('mouseup');
597+
}
595598
}
596599
},
597600

0 commit comments

Comments
 (0)