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

Commit

Permalink
fix(datepickerPopup): clear date when button is clicked
Browse files Browse the repository at this point in the history
- Fix clearing the date when the clear button is clicked

Closes #5945
Fixes #5906
  • Loading branch information
rcholic authored and wesleycho committed May 31, 2016
1 parent 4b91222 commit b0466d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/datepickerPopup/popup.js
Expand Up @@ -210,9 +210,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $

// Inner change
$scope.dateSelection = function(dt) {
if (angular.isDefined(dt)) {
$scope.date = dt;
}
$scope.date = dt;
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);
Expand Down
7 changes: 7 additions & 0 deletions src/datepickerPopup/test/popup.spec.js
Expand Up @@ -1041,6 +1041,13 @@ describe('datepicker popup', function() {
expect($rootScope.date).toBe(null);
});

it('should clear the previously selected date', function() {
$rootScope.date = new Date();
$rootScope.$digest();
buttons.eq(1).click();
expect($rootScope.date).toBe(null);
});

it('should have a button to close calendar', function() {
buttons.eq(2).click();
assignElements(wrapElement);
Expand Down

0 comments on commit b0466d9

Please sign in to comment.