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

Commit b0466d9

Browse files
rcholicwesleycho
authored andcommitted
fix(datepickerPopup): clear date when button is clicked
- Fix clearing the date when the clear button is clicked Closes #5945 Fixes #5906
1 parent 4b91222 commit b0466d9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/datepickerPopup/popup.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
210210

211211
// Inner change
212212
$scope.dateSelection = function(dt) {
213-
if (angular.isDefined(dt)) {
214-
$scope.date = dt;
215-
}
213+
$scope.date = dt;
216214
var date = $scope.date ? dateParser.filter($scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function
217215
$element.val(date);
218216
ngModel.$setViewValue(date);

src/datepickerPopup/test/popup.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,13 @@ describe('datepicker popup', function() {
10411041
expect($rootScope.date).toBe(null);
10421042
});
10431043

1044+
it('should clear the previously selected date', function() {
1045+
$rootScope.date = new Date();
1046+
$rootScope.$digest();
1047+
buttons.eq(1).click();
1048+
expect($rootScope.date).toBe(null);
1049+
});
1050+
10441051
it('should have a button to close calendar', function() {
10451052
buttons.eq(2).click();
10461053
assignElements(wrapElement);

0 commit comments

Comments
 (0)