Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(module:select, datepicker, timepicker): close dropdown when change to disable status #222

Merged
merged 3 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}