Skip to content

Commit 632a73a

Browse files
committed
fix pfDatepicker date reset on incomplete input
1 parent ae111ab commit 632a73a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/form/datepicker/datepicker.directive.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,15 @@ angular.module('patternfly.form').directive('pfDatepicker', function () {
6464

6565
//Update the date picker if there is a change on the date model
6666
$scope.$watch('date', function (newValue, oldValue) {
67+
var elemDate;
6768
if (oldValue !== newValue) {
68-
element.datepicker('update', newValue);
69+
elemDate = element.datepicker('getDate');
70+
if (!elemDate || !newValue || elemDate.getTime() !== newValue.getTime()) {
71+
//Update date picker value only when there is a change
72+
//to avoid resetting when a wrong date is typed
73+
//into input.
74+
element.datepicker('update', newValue);
75+
}
6976
}
7077
});
7178
}

0 commit comments

Comments
 (0)