1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-14 21:10:27 +01:00

Merged in AD-589-Form-Cancel-doesnt-reset (pull request #31)

fix property reset function
This commit is contained in:
TimDaubenschuetz 2015-08-06 13:51:18 +02:00
commit 716d680d0f

View File

@ -70,9 +70,9 @@ let Property = React.createClass({
}); });
} }
if(!this.state.initialValue) { if(!this.state.initialValue && childInput.props.defaultValue) {
this.setState({ this.setState({
initialValue: childInput.defaultValue initialValue: childInput.props.defaultValue
}); });
} }
}, },
@ -80,13 +80,12 @@ let Property = React.createClass({
reset() { reset() {
// maybe do reset by reload instead of front end state? // maybe do reset by reload instead of front end state?
this.setState({value: this.state.initialValue}); this.setState({value: this.state.initialValue});
if (this.refs.input.state){
// This is probably not the right way but easy fix // resets the value of a custom react component input
this.refs.input.state.value = this.state.initialValue; this.refs.input.state.value = this.state.initialValue;
}
else{ // resets the value of a plain HTML5 input
this.refs.input.getDOMNode().value = this.state.initialValue; this.refs.input.getDOMNode().value = this.state.initialValue;
}
}, },