ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

Question - Overriding the Enter Key with the Tab Key

Open jsgandalf opened this issue 11 years ago • 2 comments

We love the angular ui select plugin. I have been working on trying to override the enter key functionality with the tab key. The easiest way was to modify the uiSelect controller itself. Any other way to do this? (best practice to use maintained bower version than my own version).

https://github.com/angular-ui/ui-select/blob/master/src/uiSelectController.js#L386

Change Line 397

    function _handleDropDownSelection(key) {
          var processed = true;
          switch (key) {
            case KEY.DOWN:
              if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
              else if (ctrl.activeIndex < ctrl.items.length - 1) { ctrl.activeIndex++; }
              break;
            case KEY.UP:
              if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
              else if (ctrl.activeIndex > 0 || (ctrl.search.length === 0 && ctrl.tagging.isActivated && ctrl.activeIndex > -1)) { ctrl.activeIndex--; }
              break;
            case KEY.ENTER:
            case KEY.TAB:
              if (!ctrl.multiple || ctrl.open) ctrl.select(ctrl.items[ctrl.activeIndex], true);
              break;

jsgandalf avatar Jun 17 '15 17:06 jsgandalf

Can you explain your use case? This sounds like a very bad idea for accessibility reasons.

wesleycho avatar Mar 27 '16 22:03 wesleycho

It was a customer user case. Thanks for responding! I ended up modifying to my needs. Thanks again for checking in.

jsgandalf avatar Mar 28 '16 01:03 jsgandalf