Skip to content

Commit

Permalink
[TextField] Support padding for helperText (#19198)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshkundal authored and oliviertassinari committed Jan 13, 2020
1 parent 16fd9b7 commit 41b75fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/pages/api/form-helper-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi

| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">children</span> | <span class="prop-type">node</span> | | The content of the component. |
| <span class="prop-name">children</span> | <span class="prop-type">node</span> | | The content of the component.<br>If `' '` is provided, the component reserves one line height for displaying a future message. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> | <span class="prop-default">'p'</span> | The component used for the root node. Either a string to use a DOM element or a component. |
| <span class="prop-name">disabled</span> | <span class="prop-type">bool</span> | | If `true`, the helper text should be displayed in a disabled state. |
Expand Down
12 changes: 11 additions & 1 deletion packages/material-ui/src/FormHelperText/FormHelperText.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const styles = theme => ({

const FormHelperText = React.forwardRef(function FormHelperText(props, ref) {
const {
children,
classes,
className,
component: Component = 'p',
Expand Down Expand Up @@ -81,13 +82,22 @@ const FormHelperText = React.forwardRef(function FormHelperText(props, ref) {
)}
ref={ref}
{...other}
/>
>
{children === ' ' ? (
// eslint-disable-next-line react/no-danger
<span dangerouslySetInnerHTML={{ __html: '&#8203;' }} />
) : (
children
)}
</Component>
);
});

FormHelperText.propTypes = {
/**
* The content of the component.
*
* If `' '` is provided, the component reserves one line height for displaying a future message.
*/
children: PropTypes.node,
/**
Expand Down

0 comments on commit 41b75fe

Please sign in to comment.