From f134ca29d632ae8d03556728894dd5aa3c58f916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 5 Aug 2015 09:52:17 +0200 Subject: [PATCH] fix property reset function --- js/components/ascribe_forms/property.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/js/components/ascribe_forms/property.js b/js/components/ascribe_forms/property.js index 5f7fe603..5a72270c 100644 --- a/js/components/ascribe_forms/property.js +++ b/js/components/ascribe_forms/property.js @@ -70,23 +70,22 @@ let Property = React.createClass({ }); } - if(!this.state.initialValue) { + if(!this.state.initialValue && childInput.props.defaultValue) { this.setState({ - initialValue: childInput.defaultValue + initialValue: childInput.props.defaultValue }); } }, - reset(){ + reset() { // maybe do reset by reload instead of front end state? this.setState({value: this.state.initialValue}); - if (this.refs.input.state){ - // This is probably not the right way but easy fix - this.refs.input.state.value = this.state.initialValue; - } - else{ - this.refs.input.getDOMNode().value = this.state.initialValue; - } + + // resets the value of a custom react component input + this.refs.input.state.value = this.state.initialValue; + + // resets the value of a plain HTML5 input + this.refs.input.getDOMNode().value = this.state.initialValue; },