Skip to content

Commit

Permalink
Fixed #225
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Dec 6, 2017
1 parent 09de9f9 commit 7e1dacf
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/components/inputtextarea/InputTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,51 @@ export class InputTextarea extends Component {
this.textareaProps = Object.assign({}, this.props);
delete this.textareaProps.autoResize;
delete this.textareaProps.onInput;
delete this.textareaProps.onBlur;
delete this.textareaProps.onKeyUp;
delete this.textareaProps.onInput;
}

onFocus(e) {
if(this.props.autoResize) {
if (this.props.autoResize) {
this.resize();
}

if (this.props.onFocus) {
this.props.onFocus(e);
}
}

onBlur(e) {
if(this.props.autoResize) {
if (this.props.autoResize) {
this.resize();
}

if (this.props.onBlur) {
this.props.onBlur(e);
}
}

onKeyUp(e) {
if(this.props.autoResize) {
if (this.props.autoResize) {
this.resize();
}

if (this.props.onKeyUp) {
this.props.onKeyUp(e);
}
}

onInput(e) {
if (this.props.onInput) {
this.props.onInput();
}

if (this.props.onInput) {
this.props.onInput(e);
}

this.updateFilledState(e);
}

resize () {
Expand All @@ -56,13 +83,7 @@ export class InputTextarea extends Component {
this.textareaElement.rows = (linesCount >= parseInt(this.props.rows, 10)) ? (linesCount + 1) : parseInt(this.props.rows, 10);
}

onInput(e) {
if(this.props.onInput) {
this.props.onInput();
}

this.updateFilledState(e);
}


updateFilledState(e) {
let _filled = (e.target.value && e.target.value.length) ? true : false;
Expand Down Expand Up @@ -91,7 +112,7 @@ export class InputTextarea extends Component {

return (
<textarea {...this.textareaProps} className={className} ref={(input) => {this.textareaElement = input;}}
onFocus={this.onFocus} onBlur={this.onBlur} onKeyUp={this.onKeyUp} onInput={this.onInput}></textarea>
onFocus={this.onFocus} onBlur={this.onBlur} onKeyUp={this.onKeyUp} onInput={this.onInput}></textarea>
);
}
}

0 comments on commit 7e1dacf

Please sign in to comment.