Skip to content

Commit

Permalink
fix(module:select, datepicker, timepicker): close dropdown when chang…
Browse files Browse the repository at this point in the history
…e to disable status (#222)

* fix(module:select): close dropdown when disable select

* fix(module:datepicker): close dropdown when disable datepicker

* fix(module:timepicker): close dropdown when disable timepicker
close #190 close #195
  • Loading branch information
Zhaoming Li authored and vthinkxie committed Sep 5, 2017
1 parent 69b8979 commit 6e1b144
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/components/datepicker/nz-datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class NzDatePickerComponent implements ControlValueAccessor, OnInit {
_dropDownPosition = 'bottom';
_triggerWidth = 0;
_value = null;
_disabled = false;
_today = new Date();
_selectedMonth = moment(this.nzValue).month();
_selectedYear = moment(this.nzValue).year();
Expand All @@ -205,11 +206,20 @@ export class NzDatePickerComponent implements ControlValueAccessor, OnInit {
@Input() nzPlaceHolder = '请选择日期';
@Input() nzFormat = 'YYYY-MM-DD';
@Input() nzSize = '';
@Input() nzDisabled = false;
@ViewChild('trigger') trigger;
@ViewChild(NzTimePickerInnerComponent) timePickerInner: NzTimePickerInnerComponent;
@HostBinding('class.ant-calendar-picker') _nzCalendarPicker = true;

@Input()
get nzDisabled(): boolean {
return this._disabled;
};

set nzDisabled(value: boolean) {
this._disabled = value;
this._closeCalendar();
}

_setTriggerWidth(): void {
this._triggerWidth = this.trigger.nativeElement.getBoundingClientRect().width;
}
Expand Down Expand Up @@ -402,7 +412,6 @@ export class NzDatePickerComponent implements ControlValueAccessor, OnInit {
}

setDisabledState(isDisabled: boolean): void {
this._closeCalendar();
this.nzDisabled = isDisabled;
}
}
1 change: 1 addition & 0 deletions src/components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent

set nzDisabled(value: boolean) {
this._disabled = value;
this.closeDropDown();
this.setClassMap();
}

Expand Down
15 changes: 13 additions & 2 deletions src/components/time-picker/nz-timepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
Component,
ViewEncapsulation,
forwardRef,
ViewChild
ViewChild,
Input
} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import * as moment from 'moment';
Expand Down Expand Up @@ -137,12 +138,23 @@ import { ConnectionPositionPair } from '../core/overlay';
]
})
export class NzTimePickerComponent extends NzTimePickerInnerComponent {
_disabled = false;
_dropDownPosition = 'bottom';
_triggerWidth = 0;
_positions: ConnectionPositionPair[] = [ ...DEFAULT_DATEPICKER_POSITIONS ];

@ViewChild('trigger') trigger;

@Input()
get nzDisabled(): boolean {
return this._disabled;
};

set nzDisabled(value: boolean) {
this._disabled = value;
this._closeCalendar();
}

_setTriggerWidth(): void {
this._triggerWidth = this.trigger.nativeElement.getBoundingClientRect().width;
}
Expand Down Expand Up @@ -207,7 +219,6 @@ export class NzTimePickerComponent extends NzTimePickerInnerComponent {
}

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

0 comments on commit 6e1b144

Please sign in to comment.