Skip to content

Commit

Permalink
Allow to disable helperText place on inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMattiussi committed Feb 11, 2020
1 parent e217c8e commit 460e971
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
13 changes: 8 additions & 5 deletions packages/ra-ui-materialui/src/input/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const AutocompleteInput: FunctionComponent<
format,
fullWidth,
helperText,
disableHelperText,
id: idOverride,
input: inputOverride,
isRequired: isRequiredOverride,
Expand Down Expand Up @@ -390,11 +391,13 @@ const AutocompleteInput: FunctionComponent<
htmlFor: id,
})}
helperText={
<InputHelperText
touched={touched}
error={error}
helperText={helperText}
/>
disableHelperText ? null : (
<InputHelperText
touched={touched}
error={error}
helperText={helperText}
/>
)
}
variant={variant}
margin={margin}
Expand Down
1 change: 1 addition & 0 deletions packages/ra-ui-materialui/src/input/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const SearchInput: FunctionComponent<
hiddenLabel
label=""
resettable
disableHelperText={true}
placeholder={translate('ra.action.search')}
InputProps={{
endAdornment: (
Expand Down
15 changes: 10 additions & 5 deletions packages/ra-ui-materialui/src/input/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const SelectInput: FunctionComponent<
emptyValue,
format,
helperText,
disableHelperText,
label,
onBlur,
onChange,
Expand Down Expand Up @@ -223,11 +224,13 @@ const SelectInput: FunctionComponent<
clearAlwaysVisible
error={!!(touched && error)}
helperText={
<InputHelperText
touched={touched}
error={error}
helperText={helperText}
/>
disableHelperText ? null : (
<InputHelperText
touched={touched}
error={error}
helperText={helperText}
/>
)
}
{...options}
{...sanitizeRestProps(rest)}
Expand Down Expand Up @@ -274,6 +277,7 @@ SelectInput.propTypes = {
resource: PropTypes.string,
source: PropTypes.string,
translateChoice: PropTypes.bool,
disableHelperText: PropTypes.bool,
};

SelectInput.defaultProps = {
Expand All @@ -285,6 +289,7 @@ SelectInput.defaultProps = {
optionValue: 'id',
translateChoice: true,
disableValue: 'disabled',
disableHelperText: false,
};

export default SelectInput;
15 changes: 10 additions & 5 deletions packages/ra-ui-materialui/src/input/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const TextInput: FunctionComponent<TextInputProps> = ({
label,
format,
helperText,
disableHelperText,
onBlur,
onFocus,
onChange,
Expand Down Expand Up @@ -73,11 +74,13 @@ const TextInput: FunctionComponent<TextInputProps> = ({
}
error={!!(touched && error)}
helperText={
<InputHelperText
touched={touched}
error={error}
helperText={helperText}
/>
disableHelperText ? null : (
<InputHelperText
touched={touched}
error={error}
helperText={helperText}
/>
)
}
{...options}
{...sanitizeRestProps(rest)}
Expand All @@ -91,10 +94,12 @@ TextInput.propTypes = {
options: PropTypes.object,
resource: PropTypes.string,
source: PropTypes.string,
disableHelperText: PropTypes.bool,
};

TextInput.defaultProps = {
options: {},
disableHelperText: false,
};

export default TextInput;

0 comments on commit 460e971

Please sign in to comment.