From 7e1dacf4f9f71c3b63223967f35538cd98096492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20=C3=87ivici?= Date: Wed, 6 Dec 2017 14:00:13 +0300 Subject: [PATCH] Fixed #225 --- src/components/inputtextarea/InputTextarea.js | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/components/inputtextarea/InputTextarea.js b/src/components/inputtextarea/InputTextarea.js index 479b20b888..2d36a05623 100644 --- a/src/components/inputtextarea/InputTextarea.js +++ b/src/components/inputtextarea/InputTextarea.js @@ -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 () { @@ -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; @@ -91,7 +112,7 @@ export class InputTextarea extends Component { return ( + onFocus={this.onFocus} onBlur={this.onBlur} onKeyUp={this.onKeyUp} onInput={this.onInput}> ); } } \ No newline at end of file