Skip to content

Commit

Permalink
Better prop sanitation for reference inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kmaschta committed Dec 10, 2019
1 parent 838ceaf commit 8a13dbe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
23 changes: 2 additions & 21 deletions packages/ra-ui-materialui/src/input/ReferenceArrayInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useTranslate,
} from 'ra-core';

import sanitizeInputProps from './sanitizeRestProps';
import LinearProgress from '../layout/LinearProgress';
import Labeled from '../input/Labeled';
import ReferenceError from './ReferenceError';
Expand Down Expand Up @@ -160,33 +161,13 @@ ReferenceArrayInput.defaultProps = {
};

const sanitizeRestProps = ({
alwaysOn,
basePath,
component,
crudGetMany,
crudGetMatching,
defaultValue,
filterToQuery,
formClassName,
initializeForm,
input,
isRequired,
label,
locale,
meta,
optionText,
optionValue,
perPage,
record,
referenceSource,
resource,
allowEmpty,
source,
textAlign,
translate,
translateChoice,
...rest
}) => rest;
}) => sanitizeInputProps(rest);

export const ReferenceArrayInputView = ({
allowEmpty,
Expand Down
21 changes: 2 additions & 19 deletions packages/ra-ui-materialui/src/input/ReferenceInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Sort,
} from 'ra-core';

import sanitizeInputProps from './sanitizeRestProps';
import LinearProgress from '../layout/LinearProgress';
import Labeled from './Labeled';
import ReferenceError from './ReferenceError';
Expand Down Expand Up @@ -165,41 +166,23 @@ ReferenceInput.defaultProps = {
};

const sanitizeRestProps = ({
allowEmpty,
basePath,
choices,
className,
component,
crudGetMatching,
crudGetOne,
defaultValue,
filter,
filterToQuery,
formClassName,
initializeForm,
input,
isRequired,
label,
locale,
meta,
onChange,
optionValue,
optionText,
perPage,
record,
reference,
referenceSource,
resource,
setFilter,
setPagination,
setSort,
sort,
source,
textAlign,
translateChoice,
validation,
...rest
}: any) => rest;
}: any) => sanitizeInputProps(rest);

interface ReferenceInputViewProps {
allowEmpty?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/sanitizeRestProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default ({
allowEmpty,
alwaysOn,
basePath,
component,
Expand All @@ -16,7 +17,6 @@ export default ({
optionValue,
record,
resource,
allowEmpty,
source,
textAlign,
translate,
Expand Down

0 comments on commit 8a13dbe

Please sign in to comment.