Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextField] Support padding for helperText #19198

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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