Skip to content

Commit

Permalink
fix: fix findOption & revert type changs of validateString
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Mar 3, 2019
1 parent 119c730 commit 814fa85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions components/auto-complete/nz-autocomplete-trigger.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD
}

private resetActiveItem(): void {
if (this.nzAutocomplete.activeItem && this.nzAutocomplete.getOptionIndex(this.nzAutocomplete.activeItem)) {
this.nzAutocomplete.setActiveItem(this.nzAutocomplete.getOptionIndex(this.nzAutocomplete.activeItem));
const index = this.nzAutocomplete.getOptionIndex(this.nzAutocomplete.activeItem);
if (this.nzAutocomplete.activeItem && index !== -1) {
this.nzAutocomplete.setActiveItem(index);
} else {
this.nzAutocomplete.setActiveItem(this.nzAutocomplete.nzDefaultActiveFirstOption ? 0 : -1);
}
Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/nz-autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class NzAutocompleteComponent implements AfterViewInit, OnDestroy {

getOptionIndex(option?: NzAutocompleteOptionComponent): number {
return this.options.reduce((result: number, current: NzAutocompleteOptionComponent, index: number) => {
return result === undefined ? (option === current ? index : -1) : result;
return result === -1 ? (option === current ? index : -1) : result;
}, -1)!;
}

Expand Down
6 changes: 3 additions & 3 deletions components/form/nz-form-control.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { NzFormItemComponent } from './nz-form-item.component';
export class NzFormControlComponent extends NzColDirective implements OnDestroy, OnInit, AfterContentInit, AfterViewInit, OnDestroy {
private _hasFeedback = false;
validateChanges: Subscription | null;
validateString: string;
validateString: string | null;
controlClassMap: NgClassType = {};
iconType: string;
validateControl: FormControl | null;
Expand All @@ -60,11 +60,11 @@ export class NzFormControlComponent extends NzColDirective implements OnDestroy,
set nzValidateStatus(value: string | FormControl | FormControlName) {
if (value instanceof FormControl) {
this.validateControl = value;
this.validateString = '';
this.validateString = null;
this.watchControl();
} else if (value instanceof FormControlName) {
this.validateControl = value.control;
this.validateString = '';
this.validateString = null;
this.watchControl();
} else {
this.validateString = value;
Expand Down

0 comments on commit 814fa85

Please sign in to comment.