Skip to content

Commit

Permalink
added selectOnTab option
Browse files Browse the repository at this point in the history
  • Loading branch information
comlaterra committed May 13, 2014
1 parent 56fe6f3 commit 72c9b36
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions select2.js
Expand Up @@ -1311,6 +1311,7 @@ the specific language governing permissions and limitations under the Apache Lic
// move the global id to the correct dropdown
$("#select2-drop").removeAttr("id");
this.dropdown.attr("id", "select2-drop");

// show the elements
mask.css(_makeMaskCss());
mask.show();
Expand Down Expand Up @@ -1728,11 +1729,7 @@ the specific language governing permissions and limitations under the Apache Lic

// abstract
focusSearch: function () {
if(this.opts.mobile) {
this.search.focus();
} else {
focus(this.search);
}
focus(this.search);
},

// abstract
Expand Down Expand Up @@ -1960,10 +1957,16 @@ the specific language governing permissions and limitations under the Apache Lic
killEventImmediately(e);
return false;
case KEY.TAB:
if (!this.opts.tabOverrule) {
this.selectHighlighted({noFocus: true});
if(this.opts.selectOnTab){
this.selectHighlighted();
killEvent(e);
return;
} else {
if (!this.opts.tabOverrule) {
this.selectHighlighted({noFocus: true});
}
return;
}
return;
case KEY.ESC:
this.cancel(e);
killEventImmediately(e);
Expand Down Expand Up @@ -2541,6 +2544,10 @@ the specific language governing permissions and limitations under the Apache Lic
e.preventDefault();
this.opts.tabOverrule(e);
return;
}else if(this.opts.selectOnTab){
this.selectHighlighted();
killEvent(e);
return;
} else {
this.selectHighlighted({noFocus:true});
return;
Expand Down

0 comments on commit 72c9b36

Please sign in to comment.