Skip to content

Commit

Permalink
Change question.value onBlur event instead of onChange that happens o…
Browse files Browse the repository at this point in the history
…n every keyUp: surveyjs#173
  • Loading branch information
andrewtelnov committed Jan 3, 2017
1 parent 2ef87da commit 5401ca6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/react/reactquestiontext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ export class SurveyQuestionText extends React.Component<any, any> {
super(props);
this.question = props.question;
this.css = props.css;
this.state = { value: this.question.value };
this.state = { value: this.question.value || '' };
this.handleOnChange = this.handleOnChange.bind(this);
this.handleOnBlur = this.handleOnBlur.bind(this);
}
handleOnChange(event) {
this.setState({ value: event.target.value });
}
handleOnBlur(event) {
this.question.value = event.target.value;
this.setState({ value: this.question.value });
this.setState({ value: this.question.value || '' });
}
componentWillReceiveProps(nextProps: any) {
this.question = nextProps.question;
Expand All @@ -24,7 +28,7 @@ export class SurveyQuestionText extends React.Component<any, any> {
render(): JSX.Element {
if (!this.question) return null;
return (
<input id={this.question.inputId} className={this.css} type={this.question.inputType} value={this.question.value || ''} size={this.question.size} onChange={this.handleOnChange} />
<input id={this.question.inputId} className={this.css} type={this.question.inputType} value={this.state.value} size={this.question.size} onBlur={this.handleOnBlur} onChange={this.handleOnChange} />
);
}
}
Expand Down

0 comments on commit 5401ca6

Please sign in to comment.