) {}
ngOnInit () {
- const query = this.route.snapshot.queryParams
- if (query['search']) this.search = query['search']
-
+ this.route.queryParams
+ .pipe(first(params => this.isOnSearch() && params.search !== undefined && params.search !== null))
+ .subscribe(params => this.search = params.search)
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
}
)
}
- handleKeyUp (event: KeyboardEvent) {
+ handleKey (event: KeyboardEvent) {
event.stopImmediatePropagation()
if (!this.keyboardEventsManager) return
case 'ArrowUp':
this.keyboardEventsManager.onKeydown(event)
break
- case 'Enter':
- this.newSearch = false
- this.doSearch()
- break
}
}
+ isOnSearch () {
+ return window.location.pathname === '/search'
+ }
+
doSearch () {
+ this.newSearch = false
const queryParams: Params = {}
- if (window.location.pathname === '/search' && this.route.snapshot.queryParams) {
+ if (this.isOnSearch() && this.route.snapshot.queryParams) {
Object.assign(queryParams, this.route.snapshot.queryParams)
}