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

Add support for nodes as a proptype for errors. #685

Merged
merged 3 commits into from
Apr 18, 2018

Conversation

gjones
Copy link
Contributor

@gjones gjones commented Apr 18, 2018

I've been getting a few of these warnings while running tests in Cloud.

screen shot 2018-04-18 at 11 28 19 am

They're being caused because the error passed is a node (rather than the currently accepted string or array of strings. I spoke to @pugnascotia and @cjcenizal who agreed that we should allow node as a PropType too.

@gjones gjones requested a review from cjcenizal April 18, 2018 16:43
Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! Had a couple small comments, and then this looks good to go.

CHANGELOG.md Outdated
@@ -1,6 +1,7 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `status` prop to `EuiStep` for additional styling ([#673](https://github.com/elastic/eui/pull/673))
- Add support for node as a proptype for EuiForm and EuiFormRow errors. ([#685](https://github.com/elastic/eui/pull/685))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change the note to this? (wrapped the component names in backticks and made the note a bit terser)

`EuiForm` and `EuiFormRow` now accept nodes for `errors` prop

@@ -54,5 +54,5 @@ export const EuiForm = ({

EuiForm.propTypes = {
isInvalid: PropTypes.bool,
error: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
error: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string), PropTypes.node]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify this a bit, since node is a blanket propType which accepts strings, elements, and arrays:

error: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),

@@ -150,7 +150,7 @@ EuiFormRow.propTypes = {
label: PropTypes.node,
id: PropTypes.string,
isInvalid: PropTypes.bool,
error: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
error: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string), PropTypes.node]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants