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

Commit d0c3820

Browse files
author
DaniVarga
committed
fix minimum-input-length with refresh-delay #1898
1 parent af42092 commit d0c3820

File tree

3 files changed

+14
-115
lines changed

3 files changed

+14
-115
lines changed

npm-debug.log

-104
This file was deleted.

src/uiSelectChoicesDirective.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,26 @@ uis.directive('uiSelectChoices',
3939

4040
choices.attr('ng-repeat', parserResult.repeatExpression(groupByExp))
4141
.attr('ng-if', '$select.open'); //Prevent unnecessary watches when dropdown is closed
42-
42+
4343

4444
var rowsInner = tElement.querySelectorAll('.ui-select-choices-row-inner');
4545
if (rowsInner.length !== 1) {
4646
throw uiSelectMinErr('rows', "Expected 1 .ui-select-choices-row-inner but got '{0}'.", rowsInner.length);
4747
}
4848
rowsInner.attr('uis-transclude-append', ''); //Adding uisTranscludeAppend directive to row element after choices element has ngRepeat
4949

50-
// If IE8 then need to target rowsInner to apply the ng-click attr as choices will not capture the event.
50+
// If IE8 then need to target rowsInner to apply the ng-click attr as choices will not capture the event.
5151
var clickTarget = $window.document.addEventListener ? choices : rowsInner;
5252
clickTarget.attr('ng-click', '$select.select(' + parserResult.itemName + ',$select.skipFocusser,$event)');
53-
53+
5454
return function link(scope, element, attrs, $select) {
5555

56-
56+
5757
$select.parseRepeatAttr(attrs.repeat, groupByExp, groupFilterExp); //Result ready at $select.parserResult
5858
$select.disableChoiceExpression = attrs.uiDisableChoice;
5959
$select.onHighlightCallback = attrs.onHighlight;
60-
$select.dropdownPosition = attrs.position ? attrs.position.toLowerCase() : uiSelectConfig.dropdownPosition;
60+
$select.minimumInputLength = parseInt(attrs.minimumInputLength) || 0;
61+
$select.dropdownPosition = attrs.position ? attrs.position.toLowerCase() : uiSelectConfig.dropdownPosition;
6162

6263
scope.$watch('$select.search', function(newValue) {
6364
if(newValue && !$select.open && $select.multiple) $select.activate(false, true);

src/uiSelectController.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,14 @@ uis.controller('uiSelectCtrl',
297297
$timeout.cancel(_refreshDelayPromise);
298298
}
299299
_refreshDelayPromise = $timeout(function() {
300-
var refreshPromise = $scope.$eval(refreshAttr);
301-
if (refreshPromise && angular.isFunction(refreshPromise.then) && !ctrl.refreshing) {
302-
ctrl.refreshing = true;
303-
refreshPromise.finally(function() {
304-
ctrl.refreshing = false;
305-
});
300+
if($scope.$select.search.length >= $scope.$select.minimumInputLength){
301+
var refreshPromise = $scope.$eval(refreshAttr);
302+
if (refreshPromise && angular.isFunction(refreshPromise.then) && !ctrl.refreshing) {
303+
ctrl.refreshing = true;
304+
refreshPromise.finally(function() {
305+
ctrl.refreshing = false;
306+
});
307+
}
306308
}}, ctrl.refreshDelay);
307309
}
308310
};

0 commit comments

Comments
 (0)