diff --git a/components/time-picker/time-picker-panel.component.ts b/components/time-picker/time-picker-panel.component.ts index 7fac3f08fef..b794f7844b1 100644 --- a/components/time-picker/time-picker-panel.component.ts +++ b/components/time-picker/time-picker-panel.component.ts @@ -366,7 +366,6 @@ export class NzTimePickerPanelComponent implements ControlValueAccessor, OnInit, selectHour(hour: { index: number; disabled: boolean }): void { this.time.setHours(hour.index, hour.disabled); this.scrollToSelected(this.hourListElement.nativeElement, hour.index, 120, 'hour'); - if (!!this._disabledMinutes) { this.buildMinutes(); } diff --git a/components/time-picker/time-picker.component.spec.ts b/components/time-picker/time-picker.component.spec.ts index cc32cf0aa84..3a495210127 100644 --- a/components/time-picker/time-picker.component.spec.ts +++ b/components/time-picker/time-picker.component.spec.ts @@ -4,6 +4,7 @@ import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angu import { FormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { dispatchMouseEvent } from 'ng-zorro-antd/core/testing'; import { NzI18nModule } from '../i18n/nz-i18n.module'; import { NzTimePickerComponent } from './time-picker.component'; import { NzTimePickerModule } from './time-picker.module'; @@ -101,6 +102,26 @@ describe('time-picker', () => { fixture.detectChanges(); expect(testComponent.nzTimePickerComponent.nzFormat).toBe('h:mm:ss a'); }); + it('should support ngModelChange', fakeAsync(() => { + testComponent.date = new Date('2020-03-26 11:33:00'); + fixture.detectChanges(); + tick(500); + fixture.detectChanges(); + const nzOnChange = spyOn(testComponent, 'onChange'); + testComponent.open = true; + fixture.detectChanges(); + tick(500); + fixture.detectChanges(); + expect(overlayContainer.getContainerElement().querySelector('.ant-picker-time-panel-cell-selected > div')!.textContent).toBe('11'); + + dispatchMouseEvent(overlayContainer.getContainerElement().querySelector('.ant-picker-time-panel-cell')!, 'click'); + fixture.detectChanges(); + tick(500); + fixture.detectChanges(); + expect(nzOnChange).toHaveBeenCalled(); + const result = (nzOnChange.calls.allArgs()[0] as Date[])[0]; + expect(result.getHours()).toBe(0); + })); }); }); @@ -109,6 +130,7 @@ describe('time-picker', () => { diff --git a/package.json b/package.json index 72d8f157690..a21623d735e 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "gulp-clean": "^0.4.0", "husky": "^3.0.4", "immer": "^6.0.1", + "intersection-observer": "^0.7.0", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.3.0", @@ -114,9 +115,8 @@ "tsickle": "^0.38.1", "tslib": "^1.10.0", "tslint": "~5.18.0", - "typescript": "~3.7.4", + "typescript": "~3.8.0", "yaml-front-matter": "^4.0.0", - "intersection-observer": "^0.7.0", "zone.js": "~0.10.2" }, "lint-staged": {