Merge pull request #13104 from vvlladd28/bug/updated-datasource/dity-state

Fixed twice call registerOnChanges in datasources component
This commit is contained in:
Igor Kulikov 2025-04-08 20:16:07 +03:00 committed by GitHub
commit 71f7f5d857
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -150,7 +150,8 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
datasourcesMode: DatasourceType; datasourcesMode: DatasourceType;
private propagateChange = (_val: any) => {}; private propagateChange: (value: any) => void;
private propagateChangePending = false;
constructor(private fb: UntypedFormBuilder, constructor(private fb: UntypedFormBuilder,
private utils: UtilsService, private utils: UtilsService,
@ -161,7 +162,7 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
registerOnChange(fn: any): void { registerOnChange(fn: any): void {
this.propagateChange = fn; this.propagateChange = fn;
if (this.validate(null)) { if (this.propagateChangePending) {
setTimeout(() => { setTimeout(() => {
this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value); this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value);
}, 0); }, 0);
@ -227,7 +228,7 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
if (this.singleDatasource && !this.datasourcesFormArray.length) { if (this.singleDatasource && !this.datasourcesFormArray.length) {
this.addDatasource(false); this.addDatasource(false);
} }
if (changed) { if (changed || this.validate(null)) {
setTimeout(() => { setTimeout(() => {
this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value); this.datasourcesUpdated(this.datasourcesFormGroup.get('datasources').value);
}, 0); }, 0);
@ -329,7 +330,12 @@ export class DatasourcesComponent implements ControlValueAccessor, OnInit, Valid
if (this.datasourcesOptional) { if (this.datasourcesOptional) {
datasources = datasources ? datasources.filter(d => datasourceValid(d)) : []; datasources = datasources ? datasources.filter(d => datasourceValid(d)) : [];
} }
this.propagateChange(datasources); if (this.propagateChange) {
this.propagateChange(datasources);
this.propagateChangePending = false;
} else {
this.propagateChangePending = true;
}
} }
public onDatasourceDrop(event: CdkDragDrop<string[]>) { public onDatasourceDrop(event: CdkDragDrop<string[]>) {