Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Possible bug with the Clear button in the datepicker popup #5906

Closed
rcholic opened this issue May 18, 2016 · 1 comment
Closed

Possible bug with the Clear button in the datepicker popup #5906

rcholic opened this issue May 18, 2016 · 1 comment

Comments

@rcholic
Copy link
Contributor

rcholic commented May 18, 2016

Angular Version: 1.4.9
Bootstrap Version: 3.3.4
Angular UI Bootstrap: 1.3.2
Browser tested: Firefox and Chrome (latest)

We run into issues with the Clear button in the date picker popup, which cannot clear the date. So I did some digging in the datepicker popup.js code, and found a bug in the following code, where the null or undefined value (for dt) is not taken care of, causing the $scope.date variable to remain (therefore Clear button does not work for me):

// Inner change
  $scope.dateSelection = function(dt) {
    if (angular.isDefined(dt)) {
      $scope.date = dt;  // what if dt is null or undefined here? $scope.date is not reset then!
    } 
    var date = $scope.date ? dateParser.filter($scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function
    $element.val(date);
    ngModel.$setViewValue(date);

    if (closeOnDateSelection) {
      $scope.isOpen = false;
      $element[0].focus();
    }
  };
@rcholic rcholic changed the title Possible bug in the datepicker popup Possible bug with the Clear button in the datepicker popup May 18, 2016
@icfantv
Copy link
Contributor

icfantv commented May 27, 2016

@rcholic, at first read, this sounds legitimate. please feel free to file a PR with tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants