Skip to content
Permalink
Browse files

fix(module:date-picker): keep the time value while clicking date (#3911)

* chore(module:date-picker): keep the time value while clicking date

* chore: delete jugdement
  • Loading branch information...
wenqi73 committed Aug 8, 2019
1 parent 045eef4 commit 9499aec7972cb075dcf5a16bf8d72328d6bf930b
@@ -106,9 +106,12 @@ export class DateTableComponent implements OnInit, OnChanges {
}

private changeValueFromInside(value: CandyDate): void {
if (this.value !== value) {
this.valueChange.emit(value);
}
// Only change date not change time
const newValue = this.value
.setYear(value.getYear())
.setMonth(value.getMonth())
.setDate(value.getDate());
this.valueChange.emit(newValue);
}

private makeHeadWeekDays(): WeekDayLabel[] {
@@ -642,6 +642,20 @@ describe('NzDatePickerComponent', () => {
expect((queryFromOverlay('input.ant-calendar-input') as HTMLInputElement).value).toBe('2018-11-11 00:22:33');
}));

it('should not reset time', fakeAsync(() => {
fixtureInstance.nzValue = new Date('2019-08-02 13:03:33');
fixtureInstance.nzShowTime = true;
fixture.detectChanges();
openPickerByClickTrigger();

dispatchMouseEvent(queryFromOverlay('.ant-calendar-cell > .ant-calendar-date'), 'click');

fixture.detectChanges();
flush();
fixture.detectChanges();
expect((queryFromOverlay('input.ant-calendar-input') as HTMLInputElement).value).toBe('2019-07-29 13:03:33');
}));

it('should support nzShowTime.nzFormat', fakeAsync(() => {
fixtureInstance.nzShowTime = { nzFormat: 'HH:mm' };
fixture.detectChanges();

0 comments on commit 9499aec

Please sign in to comment.
You can’t perform that action at this time.