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

$select.refreshing=false during the refresh-delay

Open aurelienlt opened this issue 7 years ago • 1 comments

$select.refreshing is great to display hints during the refreshing. But during the refresh-delay, $select.refreshing is false and it is impossible to make a difference between no result and refreshing

http://plnkr.co/edit/yPo1KKJUI1Lk7SL5308Z?p=preview

I propose to pass $select.refreshing to true during this delay. The refresh function would look like:

ctrl.refresh = function(refreshAttr) {
  if (refreshAttr !== undefined) {
    // Debounce
    // See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L155
    // FYI AngularStrap typeahead does not have debouncing: https://github.com/mgcrea/angular-strap/blob/v2.0.0-rc.4/src/typeahead/typeahead.js#L177
    if (_refreshDelayPromise) {
      $timeout.cancel(_refreshDelayPromise);
    }
    ctrl.refreshing = true;
    _refreshDelayPromise = $timeout(function() {
      ctrl.refreshing = false;
      if ($scope.$select.search.length >= $scope.$select.minimumInputLength) {
        var refreshPromise = $scope.$eval(refreshAttr);
        if (refreshPromise && angular.isFunction(refreshPromise.then)) {
          ctrl.refreshing = true;
          refreshPromise.finally(function() {
            ctrl.refreshing = false;
          });
        }
      }
    }, ctrl.refreshDelay);
  }
};

aurelienlt avatar Jun 30 '17 15:06 aurelienlt

Hi !

I have a need for it as well, is there a plan to merge it?

cepauskas avatar May 10 '18 12:05 cepauskas