Skip to content

Commit

Permalink
add input onBlur
Browse files Browse the repository at this point in the history
  • Loading branch information
vmakhaev committed Dec 3, 2014
1 parent 65001a6 commit 608282b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/js/app-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ var AppBar = React.createClass({

});

module.exports = AppBar;
module.exports = AppBar;
21 changes: 13 additions & 8 deletions src/js/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var Input = React.createClass({
placeholder: React.PropTypes.string,
type: React.PropTypes.string,
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func
onChange: React.PropTypes.func,
onBlur: React.PropTypes.func
},

mixins: [Classable],
Expand Down Expand Up @@ -52,20 +53,20 @@ var Input = React.createClass({
'mui-error': this.props.error !== undefined && this.props.error !== null
}),
inputElement = this.props.multiline ?
this.props.valueLink ?
this.props.valueLink ?
<textarea {...this.props} className="mui-input-textarea" placeholder=""
rows={this.state.rows} /> :
<textarea {...this.props} value={this.state.value} className="mui-input-textarea"
placeholder="" rows={this.state.rows} onChange={this._onTextAreaChange} /> :
this.props.valueLink ?
rows={this.state.rows} /> :
<textarea {...this.props} value={this.state.value} className="mui-input-textarea"
placeholder="" rows={this.state.rows} onChange={this._onTextAreaChange} onBlur={this._onInputBlur} /> :
this.props.valueLink ?
<input {...this.props} ref="input" placeholder="" /> :
<input {...this.props} ref="input" value={this.state.value} placeholder=""
onChange={this._onInputChange} />;
onChange={this._onInputChange} onBlur={this._onInputBlur} />;

return (
<div ref={this.props.ref} className={classes}>
{inputElement}
<span className="mui-input-placeholder"
<span className="mui-input-placeholder"
onClick={this._onPlaceholderClick}>{this.props.placeholder}</span>
<span className="mui-input-highlight"></span>
<span className="mui-input-bar"></span>
Expand Down Expand Up @@ -93,6 +94,10 @@ var Input = React.createClass({
if (this.props.onChange) this.props.onChange(e, value);
},

_onInputBlur: function(e) {
if (this.props.onBlur) this.props.onBlur(e);
},

_onPlaceholderClick: function(e) {
this.refs.input.getDOMNode().focus();
},
Expand Down

0 comments on commit 608282b

Please sign in to comment.