Skip to content

Commit

Permalink
sanitize ReferenceInput props
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelSuwinski committed Jun 7, 2024
1 parent 3e5d533 commit c75dfc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/InputGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const IntrospectedInputGuesser = ({

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

return (
Expand All @@ -75,13 +75,13 @@ export const IntrospectedInputGuesser = ({
<SelectInput
optionText={schemaAnalyzer.getFieldNameFromSchema(field.reference)}
validate={guessedValidate}
{...(props as SelectInputProps)}
{...(rest as SelectInputProps)}
/>
</ReferenceInput>
);
}

const { filter, page, perPage, sort, enableGetChoices } =
const { filter, page, perPage, sort, enableGetChoices, ...rest } =
props as ReferenceArrayInputProps;

return (
Expand All @@ -97,7 +97,7 @@ export const IntrospectedInputGuesser = ({
<SelectArrayInput
optionText={schemaAnalyzer.getFieldNameFromSchema(field.reference)}
validate={guessedValidate}
{...(props as SelectArrayInputProps)}
{...(rest as SelectArrayInputProps)}
/>
</ReferenceArrayInput>
);
Expand Down
12 changes: 10 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,16 @@ type InputProps =
| BooleanInputProps
| NumberInputProps
| ArrayInputProps
| (ReferenceArrayInputProps & SelectArrayInputProps)
| (ReferenceInputProps & SelectInputProps)
| (Pick<
ReferenceArrayInputProps,
'filter' | 'page' | 'perPage' | 'sort' | 'enableGetChoices'
> &
SelectArrayInputProps)
| (Pick<
ReferenceInputProps,
'filter' | 'page' | 'perPage' | 'sort' | 'enableGetChoices'
> &
SelectInputProps)
| SelectArrayInputProps
| SelectInputProps;

Expand Down

0 comments on commit c75dfc5

Please sign in to comment.