Skip to content

Commit

Permalink
refactor(module:auto-complete) change previousValue setting and fix t…
Browse files Browse the repository at this point in the history
…ests (#3516)
  • Loading branch information
objectisundefined authored and simplejason committed Jun 5, 2019
1 parent 050f141 commit 15563f7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions components/auto-complete/nz-autocomplete-trigger.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD
}

openPanel(): void {
this.previousValue = this.elementRef.nativeElement.value;
this.attachOverlay();
}

Expand Down Expand Up @@ -178,19 +179,19 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD
handleInput(event: KeyboardEvent): void {
const target = event.target as HTMLInputElement;
let value: number | string | null = target.value;
if (target.type === 'number') {
value = value === '' ? null : parseFloat(value);
}
if (this.canOpen() && document.activeElement === event.target && this.previousValue !== value) {
this.previousValue = value;

if (this.canOpen() && document.activeElement === target && this.previousValue !== value) {
if (target.type === 'number') {
value = value === '' ? null : parseFloat(value);
}

this._onChange(value);
this.openPanel();
}
}

handleFocus(): void {
if (this.canOpen()) {
this.previousValue = this.elementRef.nativeElement.value;
this.openPanel();
}
}
Expand Down

0 comments on commit 15563f7

Please sign in to comment.