From 4b9066632e21cb72e729c70fc1f92826c68fe541 Mon Sep 17 00:00:00 2001 From: u-e Date: Tue, 18 Dec 2018 12:57:17 +0300 Subject: [PATCH 1/2] fixed #252 --- .../editorElements/tagArea/view/tagAreaView.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/editorElements/tagArea/view/tagAreaView.js b/src/components/editorElements/tagArea/view/tagAreaView.js index 64dc19337..ddae03f9b 100644 --- a/src/components/editorElements/tagArea/view/tagAreaView.js +++ b/src/components/editorElements/tagArea/view/tagAreaView.js @@ -38,12 +38,14 @@ export default class TagAreaView extends Component { // Component Functions _handleOnChange = (text, i) => { + const { chips } = this.state; + this.setState({ currentText: text.replace(/\s/g, ''), }); if (text.indexOf(' ') > 0 && text) { - this._handleTagAdded(); + this._handleTagAdded(chips[i] ? i : null); } if (!text && i !== 0) { this._handleTagRemove(i); @@ -52,6 +54,7 @@ export default class TagAreaView extends Component { _handleOnBlur = (i) => { this._handleTagAdded(i); + this.setState({ activeChip: null }); }; _handleTagAdded = (i = null, text = null) => { @@ -64,8 +67,8 @@ export default class TagAreaView extends Component { currentText: '', }); } else if (_currentText && chips && chips.length === chipsCount) { - let _chips = chips; - _chips[chipsCount -1] = currentText; + const _chips = chips; + _chips[chipsCount - 1] = currentText; this.setState({ chips: _chips, currentText: null, @@ -115,7 +118,9 @@ export default class TagAreaView extends Component { handleOnChange={text => this._handleOnChange(text, i)} handleOnBlur={() => this._handleOnBlur(i)} blurOnSubmit - value={activeChip === i ? currentText : chip} + value={ + activeChip === i ? currentText || chip.replace(/\s/g, '') : chip.replace(/\s/g, '') + } autoCapitalize="none" onFocus={() => this.setState({ activeChip: i })} {...this.props} From 2efa82169e53d6c53a70e68dafe6b44d33cd1318 Mon Sep 17 00:00:00 2001 From: u-e Date: Tue, 18 Dec 2018 13:02:49 +0300 Subject: [PATCH 2/2] revert --- .../editorElements/tagArea/view/tagAreaView.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/editorElements/tagArea/view/tagAreaView.js b/src/components/editorElements/tagArea/view/tagAreaView.js index ddae03f9b..64dc19337 100644 --- a/src/components/editorElements/tagArea/view/tagAreaView.js +++ b/src/components/editorElements/tagArea/view/tagAreaView.js @@ -38,14 +38,12 @@ export default class TagAreaView extends Component { // Component Functions _handleOnChange = (text, i) => { - const { chips } = this.state; - this.setState({ currentText: text.replace(/\s/g, ''), }); if (text.indexOf(' ') > 0 && text) { - this._handleTagAdded(chips[i] ? i : null); + this._handleTagAdded(); } if (!text && i !== 0) { this._handleTagRemove(i); @@ -54,7 +52,6 @@ export default class TagAreaView extends Component { _handleOnBlur = (i) => { this._handleTagAdded(i); - this.setState({ activeChip: null }); }; _handleTagAdded = (i = null, text = null) => { @@ -67,8 +64,8 @@ export default class TagAreaView extends Component { currentText: '', }); } else if (_currentText && chips && chips.length === chipsCount) { - const _chips = chips; - _chips[chipsCount - 1] = currentText; + let _chips = chips; + _chips[chipsCount -1] = currentText; this.setState({ chips: _chips, currentText: null, @@ -118,9 +115,7 @@ export default class TagAreaView extends Component { handleOnChange={text => this._handleOnChange(text, i)} handleOnBlur={() => this._handleOnBlur(i)} blurOnSubmit - value={ - activeChip === i ? currentText || chip.replace(/\s/g, '') : chip.replace(/\s/g, '') - } + value={activeChip === i ? currentText : chip} autoCapitalize="none" onFocus={() => this.setState({ activeChip: i })} {...this.props}