Skip to content

Commit

Permalink
Merge pull request #4390 from marmelab/fix-filter-form-layout
Browse files Browse the repository at this point in the history
Fix FilterForm layout broken by bottom margin on Inputs
  • Loading branch information
Luwangel authored Feb 5, 2020
2 parents 740b9b6 + 9650257 commit 27213bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/input/InputHelperText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FunctionComponent } from 'react';
import { useTranslate, ValidationError, ValidationErrorMessage } from 'ra-core';

interface Props {
helperText?: string;
helperText?: string | boolean;
error?: ValidationErrorMessage;
touched: boolean;
}
Expand All @@ -16,17 +16,17 @@ const InputHelperText: FunctionComponent<Props> = ({

return touched && error ? (
<ValidationError error={error} />
) : helperText ? (
) : typeof helperText === 'string' ? (
<>{translate(helperText, { _: helperText })}</>
) : (
) : helperText !== false ? (
// material-ui's HelperText cannot reserve space unless we pass a single
// space as child, which isn't possible when the child is a component.
// Therefore, we must reserve the space ourselves by passing the same
// markup as material-ui.
// @see https://github.com/mui-org/material-ui/blob/62e439b7022d519ab638d65201e204b59b77f8da/packages/material-ui/src/FormHelperText/FormHelperText.js#L85-L90
// eslint-disable-next-line react/no-danger
<span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
);
) : null;
};

export default InputHelperText;
1 change: 1 addition & 0 deletions packages/ra-ui-materialui/src/list/FilterFormInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const FilterFormInput = ({
record: emptyRecord,
variant,
margin,
helperText: false,
})}
<div className={classes.spacer}>&nbsp;</div>
</div>
Expand Down

0 comments on commit 27213bc

Please sign in to comment.