From 4e9694be6d4f7817d7f39536b55349c127c59765 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 4 Oct 2017 10:28:26 +0100 Subject: [PATCH] Maintain "blur to add" function to match previous UX --- src/components/views/elements/EditableItemList.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/views/elements/EditableItemList.js b/src/components/views/elements/EditableItemList.js index 6675e162c4..267244759a 100644 --- a/src/components/views/elements/EditableItemList.js +++ b/src/components/views/elements/EditableItemList.js @@ -30,19 +30,22 @@ const EditableItem = React.createClass({ onChange: PropTypes.func, onRemove: PropTypes.func, onAdd: PropTypes.func, + + addOnChange: PropTypes.bool, }, onChange: function(value) { this.setState({ value }); if (this.props.onChange) this.props.onChange(value, this.props.index); + if (this.props.addOnChange && this.props.onAdd) this.props.onAdd(value); }, onRemove: function() { - this.props.onRemove(this.props.index); + if (this.props.onRemove) this.props.onRemove(this.props.index); }, onAdd: function() { - this.props.onAdd(this.state.value); + if (this.props.onAdd) this.props.onAdd(this.state.value); }, render: function() { @@ -138,6 +141,7 @@ module.exports = React.createClass({ initialValue={this.props.newItem} onAdd={this.onItemAdded} onChange={this.onNewItemChanged} + addOnChange={true} placeholder={this.props.placeholder} /> );