From 9767260b9ab3d9b7db56c57d494f6619c31165ce Mon Sep 17 00:00:00 2001 From: Jens Vannerum Date: Wed, 14 Feb 2024 10:41:24 +0100 Subject: [PATCH] 111768: add back necessary setCurrentValue calls that were removed earlier --- .../dynamic-scrollable-dropdown.component.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts index 5e0538a1715..3142d1787f5 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts @@ -11,7 +11,7 @@ import { import { UntypedFormGroup } from '@angular/forms'; import { Observable, of as observableOf } from 'rxjs'; -import { catchError, map, tap } from 'rxjs/operators'; +import { catchError, distinctUntilChanged, map, tap } from 'rxjs/operators'; import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'; import { DynamicFormLayoutService, DynamicFormValidationService } from '@ng-dynamic-forms/core'; @@ -79,6 +79,10 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom tap(() => this.loading = false) ).subscribe((list: PaginatedList) => { this.optionsList = list.page; + if (this.model.value) { + this.setCurrentValue(this.model.value, true); + } + this.updatePageInfo( list.pageInfo.elementsPerPage, list.pageInfo.currentPage, @@ -88,6 +92,11 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom this.selectedIndex = 0; this.cdr.detectChanges(); }); + + this.group.get(this.model.id).valueChanges.pipe(distinctUntilChanged()) + .subscribe((value) => { + this.setCurrentValue(value); + }); } /**