Skip to content

Commit 2440249

Browse files
committed
[NAE-1766] Options on multichoice autocomplete do not refresh in a specific situation
- fix
1 parent f2ca1da commit 2440249

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

projects/netgrif-components-core/src/lib/data-fields/multichoice-field/multichoice-autocomplete-field/abstract-multichoice-autocomplete-field-component.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {FormControl} from '@angular/forms';
44
import {WrappedBoolean} from '../../data-field-template/models/wrapped-boolean';
55
import {COMMA, ENTER} from '@angular/cdk/keycodes';
66
import {MatChipInputEvent} from '@angular/material/chips';
7-
import {Observable, of} from 'rxjs';
8-
import {map, startWith, tap} from 'rxjs/operators';
7+
import {Observable, of, Subscription} from 'rxjs';
98
import {MultichoiceAutocompleteFilterProperty} from './multichoice-autocomplete-filter-property';
109

1110
@Component({
@@ -21,16 +20,19 @@ export abstract class AbstractMultichoiceAutocompleteFieldComponentComponent imp
2120

2221
separatorKeysCodes: number[] = [ENTER, COMMA];
2322

23+
subscriptionChangeData$: Subscription;
24+
2425
filteredOptions: Observable<Array<MultichoiceFieldValue>>;
2526

2627
ngOnInit() {
27-
this.formControlRef.valueChanges.subscribe(newVal => {
28+
this.subscriptionChangeData$ =this.formControlRef.valueChanges.subscribe(newVal => {
2829
this.filteredOptions = of(this._filter(newVal ?? '').filter((option) => !this.multichoiceField.value?.includes(option.key)));
2930
})
3031
}
3132

3233
ngOnDestroy(): void {
3334
this.filteredOptions = undefined;
35+
this.subscriptionChangeData$.unsubscribe();
3436
}
3537

3638
add(event: MatChipInputEvent): void {

0 commit comments

Comments
 (0)