]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/header/search-typeahead.component.ts
Fix search after first type on input
[github/Chocobozzz/PeerTube.git] / client / src / app / header / search-typeahead.component.ts
index 372601fa82c2c6a5fee8332d73143dc77aacce87..d0350368dab790bd80ff089e1b84a32ae0b101e4 100644 (file)
@@ -35,9 +35,9 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy {
   ) {}
 
   ngOnInit () {
-    const query = this.route.snapshot.queryParams
-    if (query['search']) this.search = query['search']
-
+    this.route.queryParams
+      .pipe(first(params => params.search !== undefined && params.search !== null))
+      .subscribe(params => this.search = params.search)
     this.serverService.getConfig()
       .subscribe(config => this.serverConfig = config)
   }
@@ -134,7 +134,7 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy {
     )
   }
 
-  handleKeyUp (event: KeyboardEvent) {
+  handleKey (event: KeyboardEvent) {
     event.stopImmediatePropagation()
     if (!this.keyboardEventsManager) return
 
@@ -143,14 +143,11 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy {
       case 'ArrowUp':
         this.keyboardEventsManager.onKeydown(event)
         break
-      case 'Enter':
-        this.newSearch = false
-        this.doSearch()
-        break
     }
   }
 
   doSearch () {
+    this.newSearch = false
     const queryParams: Params = {}
 
     if (window.location.pathname === '/search' && this.route.snapshot.queryParams) {