From 0665ef876409cdd7764d47aa5385c2e7654e8524 Mon Sep 17 00:00:00 2001 From: John Wehr Date: Tue, 24 May 2016 18:11:31 -0400 Subject: [PATCH] Fire onBlur in more situations. Automatic Example Update --- example/app.jsx | 2 +- lib/index.js | 6 ++++++ package.json | 2 +- src/index.jsx | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/example/app.jsx b/example/app.jsx index 488de96..44969b0 100755 --- a/example/app.jsx +++ b/example/app.jsx @@ -68,7 +68,7 @@ const App = React.createClass({ {this.state.focused ? "Focused" : "Blurred"} - {this.setState({focused: true})}} onBlur={() => {this.setState({focused: false})}} /> + {this.setState({focused: true})}} onBlur={() => {this.setState({focused: false})}} /> This is {this.state.focused ? "focused" : "blurred"}. diff --git a/lib/index.js b/lib/index.js index 684beac..8cf8b79 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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) { @@ -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()); } diff --git a/package.json b/package.json index 2d5f78d..a9d4a26 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/index.jsx b/src/index.jsx index 6ec1442..0f5d551 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -206,6 +206,9 @@ export default React.createClass({ this.setState({ focused: false }); + if(this.props.onBlur) { + this.props.onBlur(e); + } } }, handleFocus(e){ @@ -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()); }