ui-select
ui-select copied to clipboard
Question - Overriding the Enter Key with the Tab Key
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;
Can you explain your use case? This sounds like a very bad idea for accessibility reasons.
It was a customer user case. Thanks for responding! I ended up modifying to my needs. Thanks again for checking in.