-
-
Notifications
You must be signed in to change notification settings - Fork 208
Small fixes (floatingLabelFixed, className) and add a persistInput prop #29
Conversation
Thank you for your PR, great work! 👍
What about |
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.
Looks good! 👍
@@ -210,7 +210,9 @@ class ChipInput extends React.Component { | |||
|
|||
handleInputBlur = (event) => { | |||
if (!this.autoComplete.refs.menu) { | |||
this.setState({ isFocused: false, inputValue: '' }) | |||
if (!this.props.persistInput) this.setState({ inputValue: '' }); |
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.
Eww... a semicolon! 😃 Could you please use Standard style (no semicolons)?
I should add a linter and Travis integration, though...
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.
Sure, sorry 'bout that !
@@ -46,6 +46,7 @@ import ChipInput from 'material-ui-chip-input' | |||
| onTouchTap | `function` | | Callback function that is called when text input is clicked. | | |||
| onUpdateInput | `function` | | Callback function that is called when the input changes (useful for auto complete). | | |||
| openOnFocus | `bool` | `false` | Opens the auto complete list on focus if set to true. | | |||
| persistInput | `bool` | `false` | Persist the input value after the Component looses focus | |
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.
Should we rename this to clearOnBlur
and let it default to true
?
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.
Agreed, will do !
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.
99% done! :)
@@ -46,7 +46,7 @@ import ChipInput from 'material-ui-chip-input' | |||
| onTouchTap | `function` | | Callback function that is called when text input is clicked. | | |||
| onUpdateInput | `function` | | Callback function that is called when the input changes (useful for auto complete). | | |||
| openOnFocus | `bool` | `false` | Opens the auto complete list on focus if set to true. | | |||
| persistInput | `bool` | `false` | Persist the input value after the Component looses focus | | |||
| this.setState({ inputValue: '' }) | `bool` | `true` | Clear the input value after the Component looses focus | |
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.
Copy/paste error?
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.
Argh, sorry 'bout that
@@ -210,8 +210,11 @@ class ChipInput extends React.Component { | |||
|
|||
handleInputBlur = (event) => { | |||
if (!this.autoComplete.refs.menu) { | |||
if (!this.props.persistInput) this.setState({ inputValue: '' }); | |||
this.setState({ isFocused: false }); | |||
if (this.props.clearOnBlur !== undefined && this.props.clearOnBlur) { |
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.
This would be easier (and safer) by adding clearOnBlur: true
to the defaultProps
below.
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.
Ah, true !
Perfect, thanks again for your contribution! 🎉 |
Just to fix small issues with
className
andfloatingLabelFixed
props not being used.I also added a new prop,
persistInput
, so the input can be kept in the input field even when the element is blurred. This could be useful (at least it was for me) ; however I'm not sure for the name...Great work by the way ! 👍