Skip to content

Commit

Permalink
Merge pull request #27 from nk1tz/start-finish-hooks
Browse files Browse the repository at this point in the history
added onFinish and onStart hooks
  • Loading branch information
kaivi authored Jun 1, 2017
2 parents 8735548 + 671daa5 commit d347da2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/RIEBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export default class RIEBase extends React.Component {
classEditing: React.PropTypes.string,
classDisabled: React.PropTypes.string,
classInvalid: React.PropTypes.string,
className: React.PropTypes.string
className: React.PropTypes.string,
onFinish: React.PropTypes.func,
onStart: React.PropTypes.func
};

doValidations = (value) => {
Expand Down
2 changes: 2 additions & 0 deletions src/RIEStatefulBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export default class RIEStatefulBase extends RIEBase {
}

startEditing = () => {
this.props.onStart ? this.props.onStart() : null;
if(this.props.isDisabled) return;
this.setState({editing: true});
};

finishEditing = () => {
this.props.onFinish ? this.props.onFinish() : null;
let newValue = ReactDOM.findDOMNode(this.refs.input).value;
this.doValidations(newValue);
if(!this.state.invalid && this.props.value !== newValue) {
Expand Down

0 comments on commit d347da2

Please sign in to comment.