Skip to content

Commit

Permalink
fix(module:date-picker): fix date display of the end part is not as e…
Browse files Browse the repository at this point in the history
…xpected (#1709)

close #1693
  • Loading branch information
wilsoncook authored and vthinkxie committed Jun 25, 2018
1 parent 4868c41 commit b1a1235
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ export class DateRangePopupComponent implements OnInit, OnChanges {

getValueBySelector(partType?: RangePartType): CandyDate {
if (this.isRange) {
return this.valueForRangeShow[ this.getPartTypeIndex(partType) ];
const valueShow = this.showTimePicker ? this.value : this.valueForRangeShow; // Use the real time value that without decorations when timepicker is shown up
return valueShow[ this.getPartTypeIndex(partType) ];
} else {
return this.value as CandyDate;
}
Expand All @@ -238,11 +239,11 @@ export class DateRangePopupComponent implements OnInit, OnChanges {

disabledStartTime = (value: Date): DisabledTimeConfig => {
return this.disabledTime && this.disabledTime(value, 'start');
};
}

disabledEndTime = (value: Date): DisabledTimeConfig => {
return this.disabledTime && this.disabledTime(value, 'end');
};
}

isAllowedSelectedValue(): boolean {
const selectedValue = this.selectedValue;
Expand Down
16 changes: 16 additions & 0 deletions components/date-picker/range-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,22 @@ describe('NzRangePickerComponent', () => {
expect(queryFromOverlay('.ant-calendar-range-right .ant-calendar-selected-end-date')).toBeDefined();
}));

it('should display expected date when the range values are the same day (include the scenario of timepicker)', fakeAsync(() => {
fixtureInstance.modelValue = [ new Date('2018-05-15'), new Date('2018-05-15') ];
fixtureInstance.nzShowTime = true;
fixture.detectChanges();
openPickerByClickTrigger();

expect(queryFromOverlay('.ant-calendar-range-right .ant-calendar-month-select').textContent).toContain('6');

// Open time picker panel
dispatchMouseEvent(queryFromOverlay('.ant-calendar-time-picker-btn'), 'click');
fixture.detectChanges();
tick();
fixture.detectChanges();
expect(queryFromOverlay('.ant-calendar-range-right .ant-calendar-month-select').textContent).toContain('5');
}));

it('should support nzRanges', fakeAsync(() => {
const today = new Date();
fixtureInstance.nzRanges = { 'Today': [ today, today ] };
Expand Down

0 comments on commit b1a1235

Please sign in to comment.