Hitting Tab selects current highlighted option

While navigating through native selects using the keyboard, one can start
typing the text of the desired option to select it, then hit the Tab key
to move to the next element with the desired option remaining selected.
This doesn't work with Chosen currently (the correct option is highlighted,
but it is not selected once the Tab key is hit.)

Now the current highlighted option in a non-multiple Chosen select is
selected when the Tab key is hit.

Resolves #104.
This commit is contained in:
Adam Ford 2011-09-20 09:12:52 -06:00
parent 91734e94ee
commit 208370bd0d
6 changed files with 10 additions and 2 deletions

View file

@ -650,6 +650,9 @@
this.backstroke_length = this.search_field.val().length; this.backstroke_length = this.search_field.val().length;
break; break;
case 9: case 9:
if (this.results_showing && !this.is_multiple) {
this.result_select(evt);
}
this.mouse_on_container = false; this.mouse_on_container = false;
break; break;
case 13: case 13:

File diff suppressed because one or more lines are too long

View file

@ -653,6 +653,9 @@
case 8: case 8:
return this.backstroke_length = this.search_field.value.length; return this.backstroke_length = this.search_field.value.length;
case 9: case 9:
if (this.results_showing && !this.is_multiple) {
this.result_select(evt);
}
return this.mouse_on_container = false; return this.mouse_on_container = false;
case 13: case 13:
return evt.preventDefault(); return evt.preventDefault();

File diff suppressed because one or more lines are too long

View file

@ -539,6 +539,7 @@ class Chosen
@backstroke_length = this.search_field.val().length @backstroke_length = this.search_field.val().length
break break
when 9 when 9
this.result_select(evt) if this.results_showing and not @is_multiple
@mouse_on_container = false @mouse_on_container = false
break break
when 13 when 13

View file

@ -539,6 +539,7 @@ class Chosen
when 8 when 8
@backstroke_length = this.search_field.value.length @backstroke_length = this.search_field.value.length
when 9 when 9
this.result_select(evt) if this.results_showing and not @is_multiple
@mouse_on_container = false @mouse_on_container = false
when 13 when 13
evt.preventDefault() evt.preventDefault()