Fix search after first type on input

This commit is contained in:
Rigel Kent 2020-04-07 02:20:24 +02:00
parent 8323c435c1
commit be6343d26e
No known key found for this signature in database
GPG Key ID: 5E53E96A494E452F
2 changed files with 3 additions and 6 deletions

View File

@ -1,7 +1,7 @@
<div class="d-inline-flex position-relative" id="typeahead-container"> <div class="d-inline-flex position-relative" id="typeahead-container">
<input <input
type="text" id="search-video" name="search-video" #searchVideo i18n-placeholder placeholder="Search videos, channels…" 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> <span class="icon icon-search" (click)="doSearch()"></span>

View File

@ -134,7 +134,7 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy {
) )
} }
handleKeyUp (event: KeyboardEvent) { handleKey (event: KeyboardEvent) {
event.stopImmediatePropagation() event.stopImmediatePropagation()
if (!this.keyboardEventsManager) return if (!this.keyboardEventsManager) return
@ -143,14 +143,11 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy {
case 'ArrowUp': case 'ArrowUp':
this.keyboardEventsManager.onKeydown(event) this.keyboardEventsManager.onKeydown(event)
break break
case 'Enter':
this.newSearch = false
this.doSearch()
break
} }
} }
doSearch () { doSearch () {
this.newSearch = false
const queryParams: Params = {} const queryParams: Params = {}
if (window.location.pathname === '/search' && this.route.snapshot.queryParams) { if (window.location.pathname === '/search' && this.route.snapshot.queryParams) {