mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Improve input_textarea_toggleable
This commit is contained in:
parent
52903c6982
commit
3a11efb2fc
@ -19,20 +19,10 @@ let InputTextAreaToggable = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate() {
|
||||||
// if the components state value was changed during an update, we want to refresh it
|
// If the initial value of state.value is null, we want to set props.defaultValue
|
||||||
// in this component as well as in the parent Property
|
// as a value. In all other cases TextareaAutosize.onChange is updating.handleChange already
|
||||||
if(!this.state.value && this.state.value !== prevState.value) {
|
if(this.state.value === null && this.props.defaultValue) {
|
||||||
this.handleChange({
|
|
||||||
target: {
|
|
||||||
value: this.state.value
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, if state wasn't defined beforehand and defaultValue is defined from the outside
|
|
||||||
// we set it as the component's state and update Property by calling handleChange
|
|
||||||
if(!this.state.value && this.props.defaultValue) {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
value: this.props.defaultValue
|
value: this.props.defaultValue
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user