Skip to content

Commit

Permalink
fix(module:date-picker): fix disable time when date changes (#7236)
Browse files Browse the repository at this point in the history
Co-authored-by: hufan <[email protected]>
  • Loading branch information
AdvanceOrange and hufan authored Feb 14, 2022
1 parent f40aad9 commit ae67952
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions components/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,46 @@ describe('NzDatePickerComponent', () => {
expect(getPickerInput(fixture.debugElement).value).toBe('');
}));

it('should support updating the disabledtime state when the current time changes', fakeAsync(() => {
fixtureInstance.nzShowTime = true;
fixtureInstance.nzDisabledTime = (current: Date) => ({
nzDisabledHours: () => {
if (current) {
if (current.getMonth() === 2) {
return [0, 1, 2];
} else {
return [4, 5, 6];
}
} else {
return [7, 8, 9];
}
},
nzDisabledMinutes: () => [],
nzDisabledSeconds: () => []
});
fixture.detectChanges();
openPickerByClickTrigger();

// input disabled value
const input = getPickerInput(fixture.debugElement);
typeInElement('2020-03-14 00:00:00', input);
fixture.detectChanges();
expect(
queryFromOverlay('.ant-picker-time-panel-column li:nth-child(3)').classList.contains(
'ant-picker-time-panel-cell-disabled'
)
).toBeTruthy();

// input disabled value
typeInElement('2020-04-14 00:00:00', input);
fixture.detectChanges();
expect(
queryFromOverlay('.ant-picker-time-panel-column li:nth-child(5)').classList.contains(
'ant-picker-time-panel-cell-disabled'
)
).toBeTruthy();
}));

it('should support nzRenderExtraFooter', fakeAsync(() => {
fixtureInstance.nzRenderExtraFooter = () => fixtureInstance.tplExtraFooter;
fixture.detectChanges();
Expand Down
2 changes: 2 additions & 0 deletions components/date-picker/date-range-popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ export class DateRangePopupComponent implements OnInit, OnChanges, OnDestroy {
this.datePickerService.emitValue$.next();
}
}

this.buildTimeOptions();
}

reversedPart(part: RangePartType): RangePartType {
Expand Down

0 comments on commit ae67952

Please sign in to comment.