Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Add in-form="true" attribute #1277

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ uis.controller('uiSelectCtrl',
case KEY.ENTER:
if(ctrl.open && (ctrl.tagging.isActivated || ctrl.activeIndex >= 0)){
ctrl.select(ctrl.items[ctrl.activeIndex]); // Make sure at least one dropdown item is highlighted before adding if not in tagging mode
} else {
} else if (!$scope.inForm) {
ctrl.activate(false, true); //In case its the search input in 'multiple' mode
}
break;
Expand Down
3 changes: 3 additions & 0 deletions src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ uis.directive('uiSelect',
//Limit the number of selections allowed
$select.limit = (angular.isDefined(attrs.limit)) ? parseInt(attrs.limit, 10) : undefined;

//Do not open dropdown list and do not stop propagation to allow form submit if pressing Enter (only if dropdown list is closed)
scope.inForm = (angular.isDefined(attrs.inForm)) ? $parse(attrs.inForm)(scope) : true;

//Set reference to ngModel from uiSelectCtrl
$select.ngModel = ngModel;

Expand Down
2 changes: 1 addition & 1 deletion src/uiSelectSingleDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ uis.directive('uiSelectSingle', ['$timeout','$compile', function($timeout, $comp
return;
}

if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC || (scope.inForm && e.which == KEY.ENTER)) {
return;
}

Expand Down