Skip to content

Commit

Permalink
Fire onBlur in more situations.
Browse files Browse the repository at this point in the history
Automatic Example Update
  • Loading branch information
wehriam committed May 24, 2016
1 parent 8b7ddf2 commit 0665ef8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/app.jsx
Expand Up @@ -68,7 +68,7 @@ const App = React.createClass({
<Col sm={6}>
<FormGroup>
<ControlLabel>{this.state.focused ? "Focused" : "Blurred"}</ControlLabel>
<DatePicker placeholder="Placeholder" value={this.state.date} onFocus={() => {this.setState({focused: true})}} onBlur={() => {this.setState({focused: false})}} />
<DatePicker onChange={this.handleChange} placeholder="Placeholder" value={this.state.date} onFocus={() => {this.setState({focused: true})}} onBlur={() => {this.setState({focused: false})}} />
<HelpBlock>This is {this.state.focused ? "focused" : "blurred"}.</HelpBlock>
</FormGroup>
</Col>
Expand Down
6 changes: 6 additions & 0 deletions lib/index.js
Expand Up @@ -255,6 +255,9 @@ exports.default = _react2.default.createClass({
this.setState({
focused: false
});
if (this.props.onBlur) {
this.props.onBlur(e);
}
}
},
handleFocus: function handleFocus(e) {
Expand Down Expand Up @@ -381,6 +384,9 @@ exports.default = _react2.default.createClass({
value: newSelectedDate.toISOString(),
focused: false
});
if (this.props.onBlur) {
this.props.onBlur(new Event("Change Date"));
}
if (this.props.onChange) {
this.props.onChange(newSelectedDate.toISOString());
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,7 +11,7 @@
"picker"
],
"main": "lib/index.js",
"version": "3.0.2",
"version": "3.0.3",
"description": "React-Bootstrap based date picker.",
"directories": {
"test": "test"
Expand Down
6 changes: 6 additions & 0 deletions src/index.jsx
Expand Up @@ -206,6 +206,9 @@ export default React.createClass({
this.setState({
focused: false
});
if(this.props.onBlur) {
this.props.onBlur(e);
}
}
},
handleFocus(e){
Expand Down Expand Up @@ -329,6 +332,9 @@ export default React.createClass({
value: newSelectedDate.toISOString(),
focused: false
});
if(this.props.onBlur) {
this.props.onBlur(new Event("Change Date"));
}
if(this.props.onChange) {
this.props.onChange(newSelectedDate.toISOString());
}
Expand Down

0 comments on commit 0665ef8

Please sign in to comment.