Skip to content

Commit 73caa25

Browse files
authored
Merge pull request #1931 from bimlas/1498-refresh-taglist-on-deleting-tag
Refresh taglist to remove unused tags on deleting
2 parents 69e012a + a6af5de commit 73caa25

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

browser/main/Detail/TagSelect.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,9 @@ class TagSelect extends React.Component {
4444
}
4545

4646
removeLastTag () {
47-
let { value } = this.props
48-
49-
value = _.isArray(value)
50-
? value.slice()
51-
: []
52-
value.pop()
53-
value = _.uniq(value)
54-
55-
this.value = value
56-
this.props.onChange()
47+
this.removeTagByCallback((value) => {
48+
value.pop()
49+
})
5750
}
5851

5952
reset () {
@@ -96,15 +89,22 @@ class TagSelect extends React.Component {
9689
}
9790

9891
handleTagRemoveButtonClick (tag) {
99-
return (e) => {
100-
let { value } = this.props
101-
92+
this.removeTagByCallback((value, tag) => {
10293
value.splice(value.indexOf(tag), 1)
103-
value = _.uniq(value)
94+
}, tag)
95+
}
10496

105-
this.value = value
106-
this.props.onChange()
107-
}
97+
removeTagByCallback (callback, tag = null) {
98+
let { value } = this.props
99+
100+
value = _.isArray(value)
101+
? value.slice()
102+
: []
103+
callback(value, tag)
104+
value = _.uniq(value)
105+
106+
this.value = value
107+
this.props.onChange()
108108
}
109109

110110
render () {
@@ -118,7 +118,7 @@ class TagSelect extends React.Component {
118118
>
119119
<span styleName='tag-label'>#{tag}</span>
120120
<button styleName='tag-removeButton'
121-
onClick={(e) => this.handleTagRemoveButtonClick(tag)(e)}
121+
onClick={(e) => this.handleTagRemoveButtonClick(tag)}
122122
>
123123
<img className='tag-removeButton-icon' src='../resources/icon/icon-x.svg' width='8px' />
124124
</button>

0 commit comments

Comments
 (0)