Skip to content

Commit

Permalink
fix(forms): avoid errors with undefined enum options
Browse files Browse the repository at this point in the history
  • Loading branch information
sleidig committed Jul 2, 2024
1 parent fd50d3d commit 9ff08e2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class EnumDropdownComponent implements OnChanges {

enumEntity: ConfigurableEnum;
invalidOptions: ConfigurableEnumValue[] = [];
options: ConfigurableEnumValue[];
options: ConfigurableEnumValue[] = [];
canEdit = false;
enumValueToString = (v: ConfigurableEnumValue) => v?.label;
createNewOption: (input: string) => Promise<ConfigurableEnumValue>;
Expand All @@ -65,7 +65,7 @@ export class EnumDropdownComponent implements OnChanges {
if (changes.hasOwnProperty("enumId") || changes.hasOwnProperty("form")) {
this.invalidOptions = this.prepareInvalidOptions();
}
this.options = [...this.enumEntity?.values, ...this.invalidOptions];
this.options = [...(this.enumEntity?.values ?? []), ...this.invalidOptions];
}

private prepareInvalidOptions(): ConfigurableEnumValue[] {
Expand Down Expand Up @@ -114,6 +114,6 @@ export class EnumDropdownComponent implements OnChanges {
this.form.setValue(undefined);
}

this.options = [...this.enumEntity.values, ...this.invalidOptions];
this.options = [...(this.enumEntity?.values ?? []), ...this.invalidOptions];
}
}

0 comments on commit 9ff08e2

Please sign in to comment.