Skip to content

Commit

Permalink
Fixed #2256
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Mar 22, 2017
1 parent 977abf1 commit 847af29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const AUTOCOMPLETE_VALUE_ACCESSOR: any = {
template: `
<span [ngClass]="{'ui-autocomplete ui-widget':true,'ui-autocomplete-dd':dropdown,'ui-autocomplete-multiple':multiple}" [ngStyle]="style" [class]="styleClass">
<input *ngIf="!multiple" #in type="text" [ngStyle]="inputStyle" [class]="inputStyleClass" autocomplete="off" [ngClass]="'ui-inputtext ui-widget ui-state-default ui-corner-all'"
[value]="value ? (field ? objectUtils.resolveFieldData(value,field)||value : value) : null" (input)="onInput($event)" (keydown)="onKeydown($event)" (focus)="onInputFocus($event)" (blur)="onBlur()"
[value]="value ? (field ? objectUtils.resolveFieldData(value,field)||value : value) : null" (input)="onInput($event)" (keydown)="onKeydown($event)" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)"
[attr.placeholder]="placeholder" [attr.size]="size" [attr.maxlength]="maxlength" [attr.tabindex]="tabindex" [readonly]="readonly" [disabled]="disabled"
[ngClass]="{'ui-autocomplete-input':true,'ui-autocomplete-dd-input':dropdown}"
><ul *ngIf="multiple" class="ui-autocomplete-multiple-container ui-widget ui-inputtext ui-state-default ui-corner-all" [ngClass]="{'ui-state-disabled':disabled,'ui-state-focus':focus}" (click)="multiIn.focus()">
Expand All @@ -28,7 +28,7 @@ export const AUTOCOMPLETE_VALUE_ACCESSOR: any = {
<ng-template *ngIf="selectedItemTemplate" [pTemplateWrapper]="selectedItemTemplate" [item]="val"></ng-template>
</li>
<li class="ui-autocomplete-input-token">
<input #multiIn type="text" [disabled]="disabled" [attr.placeholder]="placeholder" [attr.tabindex]="tabindex" (input)="onInput($event)" (keydown)="onKeydown($event)" (focus)="onInputFocus($event)" (blur)="onBlur()" autocomplete="off">
<input #multiIn type="text" [disabled]="disabled" [attr.placeholder]="placeholder" [attr.tabindex]="tabindex" (input)="onInput($event)" (keydown)="onKeydown($event)" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" autocomplete="off">
</li>
</ul
><button type="button" pButton icon="fa-fw fa-caret-down" class="ui-autocomplete-dropdown" [disabled]="disabled"
Expand Down Expand Up @@ -86,6 +86,8 @@ export class AutoComplete implements AfterViewInit,DoCheck,AfterViewChecked,Cont

@Output() onFocus: EventEmitter<any> = new EventEmitter();

@Output() onBlur: EventEmitter<any> = new EventEmitter();

@Output() onDropdownClick: EventEmitter<any> = new EventEmitter();

@Input() field: string;
Expand Down Expand Up @@ -400,9 +402,10 @@ export class AutoComplete implements AfterViewInit,DoCheck,AfterViewChecked,Cont
this.onFocus.emit(event);
}

onBlur() {
onInputBlur(event) {
this.focus = false;
this.onModelTouched();
this.onBlur.emit(event);
}

onDropdownFocus() {
Expand Down
5 changes: 5 additions & 0 deletions showcase/demo/autocomplete/autocompletedemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ <h3>Events</h3>
<td>onFocus</td>
<td>event: Browser event</td>
<td>Callback to invoke when autocomplete gets focus.</td>
</tr>
<tr>
<td>onBlur</td>
<td>event: Browser event</td>
<td>Callback to invoke when autocomplete loses focus.</td>
</tr>
<tr>
<td>onSelect</td>
Expand Down

0 comments on commit 847af29

Please sign in to comment.