-
Notifications
You must be signed in to change notification settings - Fork 227
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): allow for input isValid override #374
Conversation
Codecov Report
@@ Coverage Diff @@
## master #374 +/- ##
==========================================
+ Coverage 96.94% 96.94% +<.01%
==========================================
Files 53 53
Lines 1833 1836 +3
Branches 211 212 +1
==========================================
+ Hits 1777 1780 +3
Misses 56 56
Continue to review full report at Codecov.
|
packages/text-field/Input.js
Outdated
@@ -117,7 +117,12 @@ export default class Input extends React.Component { | |||
} | |||
|
|||
isBadInput = () => this.inputElement.current.validity.badInput; | |||
isValid = () => this.inputElement.current.validity.valid; | |||
isValid = () => { | |||
if (typeof this.props.isValid === 'boolean') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're just checking to see if this prop exists, right?
if (this.props.isValid !== undefined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought I'm not sure which way of putting it is less awkward, up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did typeof this.props.isValid === 'boolean'
, because we want it to be true
or false
. If its anything else (null, undefined, 12, 'abc', etc.) then it shouldn't be considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually...I guess they would get a warning via PropTypes. I will change to your suggestion.
Created material-components/material-components-web#4054 which will include another follow up PR once completed. |
…ial-components-web-react into fix/list/allow-alternate-tags * 'master' of https://github.com/material-components/material-components-web-react: docs(menu-surface): open state & ref errors (material-components#412) fix(text-field): allow for input isValid override (material-components#374) feat(list): Add List Group and List Group Subheader (material-components#386) fix(top-app-bar): allow react elements in title (material-components#376) docs: update main component manifest on main Readme (material-components#394) docs: update roadmap (material-components#396) docs: Add web survey link in readmes (material-components#402) docs: update main README with CRA2 guidelines (material-components#393)
fixes #356