1
1
import { Observable } from 'rxjs' ;
2
2
3
3
import { map , startWith } from 'rxjs/operators' ;
4
- import { Component , ElementRef , EventEmitter , HostListener , Input , OnInit , Output , ViewChild } from '@angular/core' ;
4
+ import {
5
+ AfterViewInit ,
6
+ Component ,
7
+ ElementRef ,
8
+ EventEmitter ,
9
+ HostListener ,
10
+ Input ,
11
+ OnInit ,
12
+ Output ,
13
+ ViewChild
14
+ } from '@angular/core' ;
5
15
import { FormControl } from '@angular/forms' ;
6
16
import { ActivatedRoute , Router } from '@angular/router' ;
7
17
import { PublicBookmarksStore } from '../../public/bookmarks/store/public-bookmarks-store.service' ;
@@ -16,7 +26,7 @@ import { PaginationNotificationService } from '../../core/pagination-notificatio
16
26
import { LoginRequiredDialogComponent } from '../dialog/login-required-dialog/login-required-dialog.component' ;
17
27
import { SearchNotificationService } from '../../core/search-notification.service' ;
18
28
import { SearchDomain } from '../../core/model/search-domain.enum' ;
19
- import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete' ;
29
+ import { MatAutocompleteSelectedEvent , MatAutocompleteTrigger } from '@angular/material/autocomplete' ;
20
30
import { searchDomains } from '../../core/model/search-domains-map' ;
21
31
import { AddTagFilterToSearchDialogComponent } from './add-tag-filter-dialog/add-tag-filter-to-search-dialog.component' ;
22
32
import { DialogMeasurementsHelper } from '../../core/helper/dialog-measurements.helper' ;
@@ -27,7 +37,7 @@ import iziToast, { IziToastSettings } from 'izitoast';
27
37
templateUrl : './searchbar.component.html' ,
28
38
styleUrls : [ './searchbar.component.scss' ]
29
39
} )
30
- export class SearchbarComponent implements OnInit {
40
+ export class SearchbarComponent implements OnInit , AfterViewInit {
31
41
32
42
@Input ( )
33
43
context : string ;
@@ -39,6 +49,7 @@ export class SearchbarComponent implements OnInit {
39
49
searchTextCleared = new EventEmitter < boolean > ( ) ;
40
50
41
51
@ViewChild ( 'publicSearchBox' ) searchBoxField : ElementRef ;
52
+ @ViewChild ( MatAutocompleteTrigger ) autocompleteTrigger : MatAutocompleteTrigger ;
42
53
43
54
_userData : UserData ;
44
55
@@ -337,4 +348,9 @@ export class SearchbarComponent implements OnInit {
337
348
} ) ;
338
349
}
339
350
351
+ ngAfterViewInit ( ) : void {
352
+ this . searchBoxField . nativeElement . focus ( ) ;
353
+ this . autocompleteTrigger . closePanel ( ) ;
354
+ }
355
+
340
356
}
0 commit comments