Skip to content

Commit

Permalink
feat: FieldGuesser: props passing to SingleFieldList (linkType prop) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelSuwinski authored Mar 6, 2024
1 parent 7280f61 commit 295369b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/FieldGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
NumberFieldProps,
ReferenceArrayFieldProps,
ReferenceFieldProps,
SingleFieldListProps,
TextFieldProps,
UrlFieldProps,
} from 'react-admin';
Expand Down Expand Up @@ -65,11 +66,13 @@ const renderField = (
}

const fieldName = schemaAnalyzer.getFieldNameFromSchema(field.reference);
const { linkType, ...rest } = props as ReferenceArrayFieldProps &
Pick<SingleFieldListProps, 'linkType'>;
return (
<ReferenceArrayField
{...(props as ReferenceArrayFieldProps)}
{...(rest as ReferenceArrayFieldProps)}
reference={field.reference.name}>
<SingleFieldList>
<SingleFieldList linkType={linkType}>
<ChipField source={fieldName} key={fieldName} />
</SingleFieldList>
</ReferenceArrayField>
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import type {
ResourceProps,
ShowProps,
SimpleFormProps,
SingleFieldListProps,
TabbedFormProps,
TextFieldProps,
TextInputProps,
Expand Down Expand Up @@ -452,7 +453,7 @@ export type FieldProps =
| UrlFieldProps
| EmailFieldProps
| ArrayFieldProps
| ReferenceArrayFieldProps
| (ReferenceArrayFieldProps & Pick<SingleFieldListProps, 'linkType'>)
| EnumFieldProps
| ReferenceFieldProps;

Expand Down

0 comments on commit 295369b

Please sign in to comment.