src/uiSelectMultipleDirective.js
function _handleMatchSelection(key){
        var caretPosition = _getCaretPosition($select.searchInput[0]),
            length = $select.selected.length,
            // none  = -1,
            first = 0,
            last  = length-1,
            curr  = $selectMultiple.activeMatchIndex,
            next  = $selectMultiple.activeMatchIndex+1,
            prev  = $selectMultiple.activeMatchIndex-1,
            newIndex = curr;

        if(caretPosition > 0 || ($select.search.length && key == KEY.RIGHT)) return false;

        $select.close();

        function getNewActiveMatchIndex(){
          switch(key){
            case KEY.LEFT:
              // Select previous/first item
              if(~$selectMultiple.activeMatchIndex) return prev;
              // Select last item
              else return last;
              break;
            case KEY.RIGHT:
              // Open drop-down
              if(!~$selectMultiple.activeMatchIndex || curr === last){
                $select.activate();
                return false;
              }
              // Select next/last item
              else return next;
              break;
            case KEY.BACKSPACE:
              // Remove selected item and select previous/first
              if(~$selectMultiple.activeMatchIndex){
                if($selectMultiple.removeChoice(curr)) {
                  return prev;
                } else {
                  return curr;
                }

              } else {
                // If nothing yet selected, select last item
                return last;
              }
              break;
            case KEY.DELETE:
              // Remove selected item and select next item
              if(~$selectMultiple.activeMatchIndex){
                $selectMultiple.removeChoice($selectMultiple.activeMatchIndex);
                return curr;
              }
              else return false;
          }
        }

        newIndex = getNewActiveMatchIndex();

        if(!$select.selected.length || newIndex === false) $selectMultiple.activeMatchIndex = -1;
        else $selectMultiple.activeMatchIndex = Math.min(last,Math.max(first,newIndex));

        return true;
      }
function _handleMatchSelection(key){
        var caretPosition = _getCaretPosition($select.searchInput[0]),
            length = $select.selected.length,
            // none  = -1,
            first = 0,
            last  = length-1,
            curr  = $selectMultiple.activeMatchIndex,
            next  = $selectMultiple.activeMatchIndex+1,
            prev  = $selectMultiple.activeMatchIndex-1,
            newIndex = curr;

        if(caretPosition > 0 || ($select.search.length && key == KEY.RIGHT)) return false;

        $select.close();

        function getNewActiveMatchIndex(){
          switch(key){
            case KEY.LEFT:
              // Select previous/first item
              if(~$selectMultiple.activeMatchIndex) return prev;
              // Select last item
              else return last;
              break;
            case KEY.RIGHT:
              // Open drop-down
              if(!~$selectMultiple.activeMatchIndex || curr === last){
                $select.activate();
                return false;
              }
              // Select next/last item
              else return next;
              break;
            case KEY.BACKSPACE:
              // Remove selected item and select previous/first
              if(~$selectMultiple.activeMatchIndex){
                if($selectMultiple.removeChoice(curr)) {
                  return prev;
                } else {
                  return curr;
                }

              } else {
                // If nothing yet selected, select last item
                return last;
              }
              break;
            case KEY.DELETE:
              // Remove selected item and select next item
              if(~$selectMultiple.activeMatchIndex){
                $selectMultiple.removeChoice($selectMultiple.activeMatchIndex);
                return curr;
              }
              else return false;
          }
        }

        newIndex = getNewActiveMatchIndex();

        if(!$select.selected.length || newIndex === false) $selectMultiple.activeMatchIndex = -1;
        else $selectMultiple.activeMatchIndex = Math.min(last,Math.max(first,newIndex));

        return true;
      }
function _handleMatchSelection ( key ) { var caretPosition = _getCaretPosition ( $select . searchInput [ 0 ] ) , length = $select . selected . length , // none  = -1, first = 0 , last = length - 1 , curr = $selectMultiple . activeMatchIndex , next = $selectMultiple . activeMatchIndex + 1 , prev = $selectMultiple . activeMatchIndex - 1 , newIndex = curr ; if ( caretPosition > 0 || ( $select . search . length && key == KEY . RIGHT ) ) return false ; $select . close ( ) ; function getNewActiveMatchIndex ( ) { switch ( key ) { case KEY . LEFT : // Select previous/first item if ( ~ $selectMultiple . activeMatchIndex ) return prev ; // Select last item else return last ; break ; case KEY . RIGHT : // Open drop-down if ( ! ~ $selectMultiple . activeMatchIndex || curr === last ) { $select . activate ( ) ; return false ; } // Select next/last item else return next ; break ; case KEY . BACKSPACE : // Remove selected item and select previous/first if ( ~ $selectMultiple . activeMatchIndex ) { if ( $selectMultiple . removeChoice ( curr ) ) { return prev ; } else { return curr ; } } else { // If nothing yet selected, select last item return last ; } break ; case KEY . DELETE : // Remove selected item and select next item if ( ~ $selectMultiple . activeMatchIndex ) { $selectMultiple . removeChoice ( $selectMultiple . activeMatchIndex ) ; return curr ; } else return false ; } } newIndex = getNewActiveMatchIndex ( ) ; if ( ! $select . selected . length || newIndex === false ) $selectMultiple . activeMatchIndex = - 1 ; else $selectMultiple . activeMatchIndex = Math . min ( last , Math . max ( first , newIndex ) ) ; return true ; }
Handles selected options in "multiple" mode
Handles selected options in multiple mode