Fix search after first type on input
authorRigel Kent <sendmemail@rigelk.eu>
Tue, 7 Apr 2020 00:20:24 +0000 (02:20 +0200)
committerRigel Kent <sendmemail@rigelk.eu>
Tue, 7 Apr 2020 00:20:26 +0000 (02:20 +0200)
client/src/app/header/search-typeahead.component.html
client/src/app/header/search-typeahead.component.ts

index 46b28ed48e3bab272b3e227b752ad76445cd366e..710268664322ea2d4628830202588d2a81a0b4e4 100644 (file)
@@ -1,7 +1,7 @@
 <div class="d-inline-flex position-relative" id="typeahead-container">
   <input
     type="text" id="search-video" name="search-video" #searchVideo i18n-placeholder placeholder="Search videos, channels…"
-    [(ngModel)]="search" (ngModelChange)="onSearchChange()" (keyup)="handleKeyUp($event)"
+    [(ngModel)]="search" (ngModelChange)="onSearchChange()" (keyup)="handleKey($event)" (keydown.enter)="doSearch()"
   >
   <span class="icon icon-search" (click)="doSearch()"></span>
 
index 396a875c872c0f6f63ae98814887e9ce74b12da0..d0350368dab790bd80ff089e1b84a32ae0b101e4 100644 (file)
@@ -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) {