From da67484f31dd7003f28dfbb5a64ecbea281875df Mon Sep 17 00:00:00 2001 From: Stefan Kofler Date: Sun, 13 Jun 2021 11:55:28 +0200 Subject: [PATCH] fix(search): fix mobile autocomplete list --- src/app/features/search-bar/search-bar.component.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/features/search-bar/search-bar.component.ts b/src/app/features/search-bar/search-bar.component.ts index 051c1e437c..4ddb25363e 100644 --- a/src/app/features/search-bar/search-bar.component.ts +++ b/src/app/features/search-bar/search-bar.component.ts @@ -34,6 +34,8 @@ import { AnimationEvent } from '@angular/animations'; import { SearchItem, SearchQueryParams } from './search-bar.model'; import { getWorklogStr } from '../../util/get-work-log-str'; import { devError } from 'src/app/util/dev-error'; +import { MatAutocompleteTrigger } from '@angular/material/autocomplete'; +import { IS_MOBILE } from 'src/app/util/is-mobile'; @Component({ selector: 'search-bar', @@ -48,6 +50,7 @@ export class SearchBarComponent implements AfterViewInit, OnDestroy { @ViewChild('inputEl') inputEl!: ElementRef; @ViewChild('searchForm') searchForm!: ElementRef; + @ViewChild(MatAutocompleteTrigger) autocomplete!: MatAutocompleteTrigger; T: typeof T = T; isLoading$: BehaviorSubject = new BehaviorSubject(true); @@ -59,6 +62,7 @@ export class SearchBarComponent implements AfterViewInit, OnDestroy { private _subs: Subscription = new Subscription(); private _attachKeyDownHandlerTimeout?: number; + private _openPanelTimeout?: number; private _tasks$: Observable = this.isArchivedTasks$.pipe( switchMap((isArchivedTasks) => this._loadTasks$(isArchivedTasks)), ); @@ -208,6 +212,9 @@ export class SearchBarComponent implements AfterViewInit, OnDestroy { this.isLoading$.next(true); this.isArchivedTasks = !this.isArchivedTasks; this.isArchivedTasks$.next(this.isArchivedTasks); + if (IS_MOBILE) { + this._openPanelTimeout = window.setTimeout(() => this.autocomplete.openPanel()); + } } onAnimationEvent(event: AnimationEvent) { @@ -264,5 +271,6 @@ export class SearchBarComponent implements AfterViewInit, OnDestroy { if (this._attachKeyDownHandlerTimeout) { window.clearTimeout(this._attachKeyDownHandlerTimeout); } + if (this._openPanelTimeout) window.clearTimeout(this._openPanelTimeout); } }