Skip to content

Commit

Permalink
Merge pull request #1779 from spatster/master
Browse files Browse the repository at this point in the history
Focus dropdown filter on open
  • Loading branch information
cagataycivici committed Jan 18, 2017
2 parents 110f995 + 260877b commit acc2b94
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion components/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const DROPDOWN_VALUE_ACCESSOR: any = {
<div #panel [ngClass]="'ui-dropdown-panel ui-widget-content ui-corner-all ui-helper-hidden ui-shadow'"
[style.display]="panelVisible ? 'block' : 'none'" [ngStyle]="panelStyle" [class]="panelStyleClass">
<div *ngIf="filter" class="ui-dropdown-filter-container" (input)="onFilter($event)" (click)="$event.stopPropagation()">
<input type="text" autocomplete="off" class="ui-dropdown-filter ui-inputtext ui-widget ui-state-default ui-corner-all">
<input #filter type="text" autocomplete="off" class="ui-dropdown-filter ui-inputtext ui-widget ui-state-default ui-corner-all">
<span class="fa fa-search"></span>
</div>
<div #itemswrapper class="ui-dropdown-items-wrapper" [style.max-height]="scrollHeight||'auto'">
Expand Down Expand Up @@ -94,6 +94,8 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
@ViewChild('panel') panelViewChild: ElementRef;

@ViewChild('itemswrapper') itemsWrapperViewChild: ElementRef;

@ViewChild('filter') filterViewChild: ElementRef;

@ContentChildren(PrimeTemplate) templates: QueryList<any>;

Expand Down Expand Up @@ -271,6 +273,12 @@ export class Dropdown implements OnInit,AfterViewInit,AfterContentInit,AfterView
this.hide();
else {
this.show(this.panel,this.container);

if (this.filterViewChild != undefined) {
setTimeout(() => {
this.filterViewChild.nativeElement.focus();
}, 200);
}
}
}
}
Expand Down

0 comments on commit acc2b94

Please sign in to comment.