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

change tabindex and add custom validation #1737

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions src/bootstrap/match.tpl.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="ui-select-match" ng-hide="$select.open && $select.searchEnabled" ng-disabled="$select.disabled" ng-class="{'btn-default-focus':$select.focus}">
<span tabindex="-1"
class="btn btn-default form-control ui-select-toggle"
<span class="btn btn-default form-control ui-select-toggle"
aria-label="{{ $select.baseTitle }} activate"
ng-disabled="$select.disabled"
ng-click="$select.activate()"
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/select.tpl.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<div class="ui-select-container ui-select-bootstrap dropdown" ng-class="{open: $select.open}">
<div class="ui-select-match"></div>
<input type="search" autocomplete="off" tabindex="-1"
<input type="search" autocomplete="off"
aria-expanded="true"
aria-label="{{ $select.baseTitle }}"
aria-owns="ui-select-choices-{{ $select.generatedId }}"
aria-activedescendant="ui-select-choices-row-{{ $select.generatedId }}-{{ $select.activeIndex }}"
class="form-control ui-select-search"
placeholder="{{$select.placeholder}}"
ng-model="$select.search"
ng-show="$select.searchEnabled && $select.open">
ng-show="$select.searchEnabled && $select.open"
ng-blur="$select.inputBlur()">
<div class="ui-select-choices"></div>
<div class="ui-select-no-choice"></div>
</div>
2 changes: 2 additions & 0 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ uis.controller('uiSelectCtrl',
ctrl.clickTriggeredSelect = false;
ctrl.$filter = $filter;
ctrl.$element = $element;
ctrl.customValidation = undefined;
ctrl.inputBlur = function () { if (ctrl.customValidation) $scope.$eval(ctrl.customValidation); };

// Use $injector to check for $animate and store a reference to it
ctrl.$animate = (function () {
Expand Down
6 changes: 6 additions & 0 deletions src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ uis.directive('uiSelect',

if(attrs.tabindex){
attrs.$observe('tabindex', function(value) {
$select.tabindex = value;
$select.focusInput.attr('tabindex', value);
$select.searchInput.attr('tabindex', value);
element.removeAttr('tabindex');
});
}

attrs.$observe('validation', function () {
$select.customValidation = attrs.validation;
});

scope.$watch(function () { return scope.$eval(attrs.searchEnabled); }, function(newVal) {
$select.searchEnabled = newVal !== undefined ? newVal : uiSelectConfig.searchEnabled;
});
Expand Down