Skip to content

Commit

Permalink
Merge pull request #44 from Aweary/master
Browse files Browse the repository at this point in the history
Add custom onBlur and onFocus handler support
  • Loading branch information
mbrookes committed Jan 28, 2016
2 parents e110e0e + 46c194c commit 841f58d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/FormsyText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ let FormsyText = React.createClass({

propTypes: {
name: React.PropTypes.string.isRequired,
value: React.PropTypes.string
value: React.PropTypes.string,
onFocus: React.PropTypes.func,
onBlur: React.PropTypes.func
},

handleChange: function handleChange(event) {
Expand All @@ -29,6 +31,7 @@ let FormsyText = React.createClass({

handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
if (this.props.onBlur) this.props.onBlur(event);
},

handleEnterKeyDown: function handleEnterKeyDown(event) {
Expand All @@ -42,6 +45,7 @@ let FormsyText = React.createClass({
defaultValue={this.props.value}
onChange={this.handleChange}
onBlur={this.handleBlur}
onFocus={this.props.onFocus}
onEnterKeyDown={this.handleEnterKeyDown}
errorText={this.getErrorMessage()}
value={this.getValue()}
Expand Down

0 comments on commit 841f58d

Please sign in to comment.