Skip to content

Commit 400b560

Browse files
committed
Set selected and date variables to undefined on clear in date directive.
1 parent 05bf82a commit 400b560

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/date-input.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ directive('dateInput', ['$document', function ($document) {
3535
// Update selected date
3636
scope.setDate = function (date, calendar_update) {
3737
if ( scope.selected.isSame(date) ) { return; }
38-
scope.selected.year(date.year()).month(date.month()).date(date.date()).hours(date.hours()).minutes(date.minutes()).seconds(date.seconds());
39-
if ( scope.selected.clone().startOf('week').month() !== scope.calendar.month() || calendar_update ) {
40-
scope.calendar = scope.selected.clone();
38+
if ( !date ) {
39+
scope.selected = scope.date = undefined;
40+
} else {
41+
scope.selected.year(date.year()).month(date.month()).date(date.date()).hours(date.hours()).minutes(date.minutes()).seconds(date.seconds());
42+
if ( scope.selected.clone().startOf('week').month() !== scope.calendar.month() || calendar_update ) {
43+
scope.calendar = scope.selected.clone();
44+
}
4145
}
4246
scope.onChange();
4347
};

0 commit comments

Comments
 (0)