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