Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Small fixes (floatingLabelFixed, className) and add a persistInput prop #29

Merged
merged 9 commits into from
Oct 18, 2016

Conversation

ngotchac
Copy link
Contributor

Just to fix small issues with className and floatingLabelFixed 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 ! 👍

@leMaik
Copy link
Member

leMaik commented Oct 18, 2016

Thank you for your PR, great work! 👍

so the input can be kept in the input field even when the element is blurred [...] however I'm not sure for the name

What about clearOnBlur which defaults to false? 😉 That would describe what it does without any further documentation.

Copy link
Member

@leMaik leMaik left a 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: '' });
Copy link
Member

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...

Copy link
Contributor Author

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 |
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, will do !

Copy link
Member

@leMaik leMaik left a 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 |
Copy link
Member

Choose a reason for hiding this comment

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

Copy/paste error?

Copy link
Contributor Author

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) {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, true !

@leMaik leMaik merged commit 496e715 into TeamWertarbyte:master Oct 18, 2016
@leMaik
Copy link
Member

leMaik commented Oct 18, 2016

Perfect, thanks again for your contribution! 🎉

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

Successfully merging this pull request may close these issues.

2 participants