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

fix(text-field): custom validation #430

Merged

Conversation

hvolschenk
Copy link
Contributor

fixes #421

This does fix the issue, I am just not sure if this is how you want it to be fixed 😊

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@hvolschenk hvolschenk force-pushed the fix/text-field-custom-validation branch from 5e3d328 to 2586c48 Compare November 12, 2018 16:51
@googlebot
Copy link

CLAs look good, thanks!

@codecov-io
Copy link

codecov-io commented Nov 12, 2018

Codecov Report

Merging #430 into rc7.0 will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##            rc7.0     #430      +/-   ##
==========================================
+ Coverage   96.14%   96.16%   +0.01%     
==========================================
  Files          55       55              
  Lines        1841     1849       +8     
  Branches      214      217       +3     
==========================================
+ Hits         1770     1778       +8     
  Misses         71       71
Impacted Files Coverage Δ
packages/text-field/Input.js 95.78% <100%> (+0.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 647ff52...3db88a9. Read the comment docs.

@moog16 moog16 changed the title Fix/text field custom validation fix(text-field): custom validation Nov 13, 2018
@@ -79,6 +91,15 @@ export default class Input extends React.Component {
}
});
}

if (isValid !== prevProps.isValid) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks good and makes sense to me, but what are we solving. I ran your example in #421. I am confused what the issue was.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue was/is that in the example there is some custom validation.

To make the validation message appear I needed to focus the field, blur it, focus it again, and then blur it a second time for the validation message to appear.

Copy link
Contributor

Choose a reason for hiding this comment

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

gotcha...interesting that it doesn't show up on the screenshot tests. I added isValid={false} on the , and it worked as expected.

@moog16
Copy link
Contributor

moog16 commented Nov 13, 2018

@hvolschenk I agree we should rework the API for validation. Did you ever take a look at this documentation: https://github.com/material-components/material-components-web-react/tree/master/packages/text-field/helper-text#input-validation?

We just did some text field updates, and were going to rework part of MDC Web's text field after this is fixed: material-components/material-components-web#4054. Your changes in the componentDidUpdate make sense. Could you please update the documentation in both the helper-text Readme and the main text-field readme? Thanks for all your contributions!

remove check for `setUseNativeValidation` method as it will always exist
make sure `setUseNativeValidation` is available in all stubbed unit tests
@hvolschenk
Copy link
Contributor Author

@moog16 I have updated the helper-text README.md to show custom validation. Not quite sure what to add in the main README.md. Should I add a reference to the helper-text one? Or create a duplicate example of the custom validation?

return (
<HelperText
isValid={false}
isValidationMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you're saying in #421. let's remove isValidationMessage or validation as well and make them the same. If you wanna make this a different task we can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's please solve this through #435 if that's all right.

Copy link
Contributor

@moog16 moog16 left a comment

Choose a reason for hiding this comment

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

changes look good, and readme update looks good. Just a few comments. If you decide to also change isValidationMessage/validation lmk and i'll review that piece too. Otherwise we can open another issue.

@moog16
Copy link
Contributor

moog16 commented Nov 13, 2018

@hvolschenk please also sign the PR

…ng standards

change double quotes to single quotes in all jsx examples
use `isValid` state properly in custom validation example
@hvolschenk
Copy link
Contributor Author

I signed it

@moog16 moog16 changed the base branch from master to rc7.0 November 13, 2018 23:09
@moog16
Copy link
Contributor

moog16 commented Nov 13, 2018

Thanks! I changed the base to rc7.0. And will wait for #436 to pass, then merge it!

@moog16 moog16 merged commit 3a8447a into material-components:rc7.0 Nov 13, 2018
@hvolschenk hvolschenk deleted the fix/text-field-custom-validation branch November 14, 2018 05:59
moog16 pushed a commit that referenced this pull request Nov 20, 2018
moog16 pushed a commit that referenced this pull request Nov 20, 2018
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.

None yet

4 participants