Fix a couple of bugs with EditableItemList

- fix entering the same thing twice (which had the bug of not emptying the "new" field)
 - fix editing items in the list (which would stack overflow because of typo)
This commit is contained in:
Luke Barnard 2017-10-04 13:15:38 +01:00
parent 1938a767a2
commit 9e3954865a
2 changed files with 4 additions and 2 deletions

View file

@ -104,7 +104,7 @@ module.exports = React.createClass({
if (value.length === 0) { if (value.length === 0) {
this.onItemRemoved(index); this.onItemRemoved(index);
} else { } else {
this.onItemEdited(value, index); this.props.onItemEdited(value, index);
} }
}, },

View file

@ -65,7 +65,9 @@ module.exports = React.createClass({
}, },
componentWillReceiveProps: function(nextProps) { componentWillReceiveProps: function(nextProps) {
if (nextProps.initialValue !== this.props.initialValue) { if (nextProps.initialValue !== this.props.initialValue ||
nextProps.initialValue !== this.value
) {
this.value = nextProps.initialValue; this.value = nextProps.initialValue;
if (this.refs.editable_div) { if (this.refs.editable_div) {
this.showPlaceholder(!this.value); this.showPlaceholder(!this.value);