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 #16)

Form cancel doesnt reset property/form
This commit is contained in:
TimDaubenschuetz 2015-07-22 15:19:25 +02:00
commit da7be7bb06
2 changed files with 11 additions and 7 deletions

View File

@ -328,8 +328,7 @@ let EditionPersonalNote = React.createClass({
rows={1} rows={1}
editable={true} editable={true}
defaultValue={this.props.edition.note_from_user} defaultValue={this.props.edition.note_from_user}
placeholder={getLangText('Enter a personal note%s', '...')} placeholder={getLangText('Enter a personal note%s', '...')}/>
required="required"/>
</Property> </Property>
<Property hidden={true} name='bitcoin_id'> <Property hidden={true} name='bitcoin_id'>
<input defaultValue={this.props.edition.bitcoin_id}/> <input defaultValue={this.props.edition.bitcoin_id}/>

View File

@ -57,13 +57,15 @@ let Property = React.createClass({
}); });
} }
this.setState({ if(!this.state.initialValue) {
initialValue: this.refs.input.getDOMNode().defaultValue this.setState({
}); initialValue: this.refs.input.getDOMNode().defaultValue
});
}
}, },
reset(){ reset(){
// maybe do reset by reload instead of frontend 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){ if (this.refs.input.state){
// This is probably not the right way but easy fix // This is probably not the right way but easy fix
@ -117,7 +119,10 @@ let Property = React.createClass({
handleSuccess(){ handleSuccess(){
this.setState({ this.setState({
isFocused: false, isFocused: false,
errors: null errors: null,
// also update initialValue in case of the user updating and canceling its actions again
initialValue: this.refs.input.getDOMNode().value
}); });
}, },