Fix: incomplete typing for reference input (#562) · api-platform/admin@a7827cb · GitHub
Skip to content

Commit a7827cb

Browse files
Fix: incomplete typing for reference input (#562)
1 parent e0c087f commit a7827cb

4 files changed

Lines changed: 53 additions & 8 deletions

File tree

‎src/InputGuesser.test.tsx‎

Lines changed: 24 additions & 0 deletions

‎src/InputGuesser.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const IntrospectedInputGuesser = ({
5959

6060
if (field.reference !== null && typeof field.reference === 'object') {
6161
if (field.maxCardinality === 1) {
62-
const { filter, page, perPage, sort, enableGetChoices } =
62+
const { filter, page, perPage, sort, enableGetChoices, ...rest } =
6363
props as ReferenceInputProps;
6464

6565
return (
@@ -75,13 +75,13 @@ export const IntrospectedInputGuesser = ({
7575
<SelectInput
7676
optionText={schemaAnalyzer.getFieldNameFromSchema(field.reference)}
7777
validate={guessedValidate}
78-
{...(props as SelectInputProps)}
78+
{...(rest as SelectInputProps)}
7979
/>
8080
</ReferenceInput>
8181
);
8282
}
8383

84-
const { filter, page, perPage, sort, enableGetChoices } =
84+
const { filter, page, perPage, sort, enableGetChoices, ...rest } =
8585
props as ReferenceArrayInputProps;
8686

8787
return (
@@ -97,7 +97,7 @@ export const IntrospectedInputGuesser = ({
9797
<SelectArrayInput
9898
optionText={schemaAnalyzer.getFieldNameFromSchema(field.reference)}
9999
validate={guessedValidate}
100-
{...(props as SelectArrayInputProps)}
100+
{...(rest as SelectArrayInputProps)}
101101
/>
102102
</ReferenceArrayInput>
103103
);

‎src/__fixtures__/parsedData.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,17 @@ export const API_FIELDS_DATA = [
111111
enum: { Epic: 'EPIC', 'Fairy tale': 'FAIRY_TALE', Myth: 'MYTH' },
112112
required: false,
113113
}),
114+
new Field('owner', {
115+
id: 'http://localhost/owner',
116+
range: 'https://schema.org/Person',
117+
reference: {
118+
id: 'https://schema.org/Person',
119+
name: 'users',
120+
url: 'http://localhost/users',
121+
fields: [],
122+
},
123+
embedded: null,
124+
maxCardinality: 1,
125+
required: false,
126+
}),
114127
];

‎src/types.ts‎

Lines changed: 12 additions & 4 deletions

0 commit comments

Comments
 (0)