Skip to content

Commit

Permalink
fix(module:date-picker): set formControl disabled not work (#5126)
Browse files Browse the repository at this point in the history
close #5118
  • Loading branch information
wenqi73 authored Apr 24, 2020
1 parent 1eca795 commit b83e7b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,14 @@ describe('NzDatePickerComponent', () => {
fixture.detectChanges();
expect(getPickerInput(fixture.debugElement).value!.trim()).toBe('2020-04-08');
}));

it('should disabled work', fakeAsync(() => {
fixtureInstance.control = new FormControl({ value: new Date('2020-04-24'), disabled: true });
fixture.detectChanges();
flush();
fixture.detectChanges();
expect(getPickerInput(fixture.debugElement).getAttribute('disabled')).not.toBeNull();
}));
});

////////////
Expand Down
5 changes: 5 additions & 0 deletions components/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ export class NzDatePickerComponent implements OnInit, OnChanges, OnDestroy, Cont
this.onTouchedFn = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
this.cdr.markForCheck();
}

// ------------------------------------------------------------------------
// | Internal methods
// ------------------------------------------------------------------------
Expand Down

0 comments on commit b83e7b5

Please sign in to comment.