vestman / Select-or-Die

Yet another jQuery plugin to style select elements. Demo at http://vst.mn/selectordie/
MIT License
524 stars 133 forks source link

select is not updated on tabing #26

Open johanroug opened 9 years ago

johanroug commented 9 years ago

If hte dropdown is selected but not folded out, and I navigate with arrow keys, the select is not updated when I tab. Only when I click enter.

johanroug commented 9 years ago

It seems you can solve it like so

// Set $optionNext and $optionCycle if ( e.which === 37 || e.which === 38 ) { // Left/Up key console.log($optionActive) $optionNext = $optionActive.prevAll(":not('.disabled, .optgroup')").first(); $optionCycle = $sodOptions.not(".disabled, .optgroup").last();

                    if ( !$sod.hasClass("open") ) {
                        $optionNext.click();
                    }
                }
                else if ( e.which === 39 || e.which === 40 ) { // Right/Down key
                    $optionNext  = $optionActive.nextAll(":not('.disabled, .optgroup')").first();
                    $optionCycle = $sodOptions.not(".disabled, .optgroup").first();

                    if ( !$sod.hasClass("open") ) {
                        $optionNext.click();
                    }
                }