Merge pull request #24925 from backstage/blam/mutli-entity-picker-fix
scaffolder: `formData` should be allowed to be undefined
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-react': patch
|
||||
'@backstage/plugin-scaffolder': patch
|
||||
---
|
||||
|
||||
Fixing bug in `formData` type as it should be `optional` as it's possibly undefined
|
||||
@@ -304,7 +304,7 @@ export interface ScaffolderRJSFFieldProps<
|
||||
disabled: boolean;
|
||||
errorSchema?: ErrorSchema<T>;
|
||||
formContext?: F;
|
||||
formData: T;
|
||||
formData?: T;
|
||||
hideError?: boolean;
|
||||
idPrefix?: string;
|
||||
idSchema: IdSchema<T>;
|
||||
|
||||
@@ -64,7 +64,7 @@ export interface ScaffolderRJSFFieldProps<
|
||||
/** The tree of unique ids for every child field */
|
||||
idSchema: IdSchema<T>;
|
||||
/** The data for this field */
|
||||
formData: T;
|
||||
formData?: T;
|
||||
/** The tree of errors for this field and its children */
|
||||
errorSchema?: ErrorSchema<T>;
|
||||
/** The field change event handler; called with the updated form data and an optional `ErrorSchema` */
|
||||
|
||||
@@ -115,7 +115,7 @@ export const MultiEntityPicker = (props: MultiEntityPickerProps) => {
|
||||
}
|
||||
|
||||
// We need to check against formData here as that's the previous value for this field.
|
||||
if (formData.includes(ref) || allowArbitraryValues) {
|
||||
if (formData?.includes(ref) || allowArbitraryValues) {
|
||||
return entityRef;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ export const MultiEntityPicker = (props: MultiEntityPickerProps) => {
|
||||
required={required}
|
||||
InputProps={{
|
||||
...params.InputProps,
|
||||
required: formData.length === 0 && required,
|
||||
required: formData?.length === 0 && required,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user