Skip to content

Commit

Permalink
#47: allow disabling initial focusing of input field
Browse files Browse the repository at this point in the history
  • Loading branch information
macjohnny committed Sep 26, 2018
1 parent 6581f67 commit f8dad27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Furthermore, it provides the following inputs:
* Useful for server-side filtering. See [#3](https://github.com/bithost-gmbh/ngx-mat-select-search/issues/3)
*/
@Input() clearSearchInput = false;

/** Disables initial focusing of the input field */
@Input() disableInitialFocus = false;
```

#### Customize clear icon
Expand Down
7 changes: 6 additions & 1 deletion src/app/mat-select-search/mat-select-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ export class MatSelectSearchComponent implements OnInit, OnDestroy, AfterViewIni
*/
@Input() clearSearchInput = true;

/** Disables initial focusing of the input field */
@Input() disableInitialFocus = false;

/** Reference to the search input field */
@ViewChild('searchSelectInput', {read: ElementRef}) searchSelectInput: ElementRef;

Expand Down Expand Up @@ -187,7 +190,9 @@ export class MatSelectSearchComponent implements OnInit, OnDestroy, AfterViewIni
if (opened) {
// focus the search field when opening
this.getWidth();
this._focus();
if (!this.disableInitialFocus) {
this._focus();
}
} else {
// clear it when closing
this._reset();
Expand Down

0 comments on commit f8dad27

Please sign in to comment.