diff --git a/browser/main/Detail/TagSelect.js b/browser/main/Detail/TagSelect.js
index e45d05bc..d14c7a8c 100644
--- a/browser/main/Detail/TagSelect.js
+++ b/browser/main/Detail/TagSelect.js
@@ -44,16 +44,9 @@ class TagSelect extends React.Component {
}
removeLastTag () {
- let { value } = this.props
-
- value = _.isArray(value)
- ? value.slice()
- : []
- value.pop()
- value = _.uniq(value)
-
- this.value = value
- this.props.onChange()
+ this.removeTagByCallback((value) => {
+ value.pop()
+ })
}
reset () {
@@ -96,15 +89,22 @@ class TagSelect extends React.Component {
}
handleTagRemoveButtonClick (tag) {
- return (e) => {
- let { value } = this.props
-
+ this.removeTagByCallback((value, tag) => {
value.splice(value.indexOf(tag), 1)
- value = _.uniq(value)
+ }, tag)
+ }
- this.value = value
- this.props.onChange()
- }
+ removeTagByCallback (callback, tag = null) {
+ let { value } = this.props
+
+ value = _.isArray(value)
+ ? value.slice()
+ : []
+ callback(value, tag)
+ value = _.uniq(value)
+
+ this.value = value
+ this.props.onChange()
}
render () {
@@ -118,7 +118,7 @@ class TagSelect extends React.Component {
>
#{tag}