|
1 |
| -import { Component, Inject, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; |
| 1 | +import { |
| 2 | + Component, |
| 3 | + HostListener, |
| 4 | + Inject, |
| 5 | + OnChanges, |
| 6 | + OnDestroy, |
| 7 | + OnInit, |
| 8 | + SimpleChanges, |
| 9 | + ViewChild |
| 10 | +} from '@angular/core'; |
2 | 11 | import { FormControl } from '@angular/forms';
|
| 12 | +import { MatAutocompleteTrigger } from '@angular/material/autocomplete'; |
3 | 13 | import { Subject } from 'rxjs';
|
4 | 14 | import { debounceTime, distinctUntilChanged, map, startWith, takeUntil } from 'rxjs/operators';
|
5 | 15 |
|
@@ -44,12 +54,13 @@ import { ConfigurationService } from '../../../services/configuration.service';
|
44 | 54 | `]
|
45 | 55 | })
|
46 | 56 | export class AutocompleteActivityPicklistQuestion extends BaseActivityPicklistQuestion implements OnInit, OnDestroy, OnChanges {
|
47 |
| - private readonly ngUnsubscribe = new Subject(); |
| 57 | + @ViewChild(MatAutocompleteTrigger, {read: MatAutocompleteTrigger}) autoComplete: MatAutocompleteTrigger; |
48 | 58 |
|
49 | 59 | filteredGroups: ActivityPicklistNormalizedGroup[] = [];
|
50 | 60 | // options w/o a group
|
51 | 61 | filteredOptions: ActivityPicklistOption[] = [];
|
52 | 62 | inputFormControl = new FormControl();
|
| 63 | + private readonly ngUnsubscribe = new Subject(); |
53 | 64 |
|
54 | 65 | constructor(
|
55 | 66 | translate: NGXTranslateService,
|
@@ -169,4 +180,10 @@ export class AutocompleteActivityPicklistQuestion extends BaseActivityPicklistQu
|
169 | 180 | displayAutoComplete(option: ActivityPicklistOption | string): string {
|
170 | 181 | return typeof option === 'string' ? option : (option?.optionLabel || '');
|
171 | 182 | }
|
| 183 | + |
| 184 | + @HostListener('window: scroll') public onWindowScroll(): void { |
| 185 | + if (this.autoComplete?.panelOpen) { |
| 186 | + this.autoComplete.closePanel(); |
| 187 | + } |
| 188 | + } |
172 | 189 | }
|
0 commit comments