Skip to content

Commit

Permalink
fix: default value array handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter authored and sleidig committed Jun 7, 2024
1 parent f533ff7 commit 56037ed
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export class HandleDefaultValuesUseCase {
return;
}

if (change.length != null && change.length === 1) {
change = change[0];
}

let parentEntity: Entity = await this.entityMapper.load(
Entity.extractTypeFromId(change),
change,
Expand All @@ -103,7 +107,7 @@ export class HandleDefaultValuesUseCase {
}

if (isArray) {
targetFormControl.setValue([parentEntity[defaultValueConfig.field]]);
targetFormControl.setValue([...parentEntity[defaultValueConfig.field]]);
} else {
targetFormControl.setValue(parentEntity[defaultValueConfig.field]);
}
Expand Down Expand Up @@ -193,7 +197,7 @@ export class HandleDefaultValuesUseCase {
return false;
}

if (isArray && formControl.value && formControl.value.size > 0) {
if (isArray && formControl.value && formControl.value.length > 0) {
return false;
}

Expand Down

0 comments on commit 56037ed

Please sign in to comment.