Skip to content

Commit

Permalink
fix valueLink with multiline textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Feb 6, 2015
1 parent 5eb1421 commit 5ac6cc7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/js/enhanced-textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var EnhancedTextarea = React.createClass({

getInitialState: function() {
return {
height: this.props.rows * 24
height: this.props.rows * 24
};
},

Expand All @@ -32,7 +32,8 @@ var EnhancedTextarea = React.createClass({
onHeightChange,
textareaClassName,
rows,
...other
valueLink,
...other,
} = this.props;

var classes = this.getClasses('mui-enhanced-textarea');
Expand All @@ -41,10 +42,16 @@ var EnhancedTextarea = React.createClass({
height: this.state.height + 'px'
};

var itemProps = {};

if (this.props.textareaClassName) {
textareaClassName += ' ' + this.props.textareaClassName;
}

if (this.props.hasOwnProperty('valueLink')) {
other.value = valueLink.value;
}

return (
<div className={classes}>
<textarea
Expand Down Expand Up @@ -80,8 +87,12 @@ var EnhancedTextarea = React.createClass({
if (this.props.onHeightChange) this.props.onHeightChange(e, newHeight);
}

if (this.props.hasOwnProperty('valueLink')) {
this.props.valueLink.requestChange(e.target.value);
}

if (this.props.onChange) this.props.onChange(e);
}
});

module.exports = EnhancedTextarea;
module.exports = EnhancedTextarea;

0 comments on commit 5ac6cc7

Please sign in to comment.