Skip to content

Commit

Permalink
Merge pull request #311 from nchaulet/nc-fix-valuelinkwithmultilinete…
Browse files Browse the repository at this point in the history
…xtfield

fix valueLink with multiline textarea - Fixes #312
  • Loading branch information
Hai Nguyen committed Feb 6, 2015
2 parents 5eb1421 + 813d441 commit 0eb0c4d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 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 @@ -45,6 +46,10 @@ var EnhancedTextarea = React.createClass({
textareaClassName += ' ' + this.props.textareaClassName;
}

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

return (
<div className={classes}>
<textarea
Expand Down Expand Up @@ -80,8 +85,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 0eb0c4d

Please sign in to comment.