Skip to content

Commit 52b3068

Browse files
committed
Refresh taglist to remove unused tags on deleting
When a tag is deleted from a note, the taglist did not updated: the deleted tag was still in the list. If the tag was created in the current session, it was removed, worked as expected. The reason is: until the note is not updated, the tag list is not initialized for first in the "delete tag button" handler, but it works in the second case. Tried out using backspace to delete the tag, it works.
1 parent 7b39ab4 commit 52b3068

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

browser/main/Detail/TagSelect.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,16 @@ class TagSelect extends React.Component {
9696
}
9797

9898
handleTagRemoveButtonClick (tag) {
99-
return (e) => {
100-
let { value } = this.props
99+
let { value } = this.props
101100

102-
value.splice(value.indexOf(tag), 1)
103-
value = _.uniq(value)
101+
value = _.isArray(value)
102+
? value.slice()
103+
: []
104+
value.splice(value.indexOf(tag), 1)
105+
value = _.uniq(value)
104106

105-
this.value = value
106-
this.props.onChange()
107-
}
107+
this.value = value
108+
this.props.onChange()
108109
}
109110

110111
render () {
@@ -118,7 +119,7 @@ class TagSelect extends React.Component {
118119
>
119120
<span styleName='tag-label'>#{tag}</span>
120121
<button styleName='tag-removeButton'
121-
onClick={(e) => this.handleTagRemoveButtonClick(tag)(e)}
122+
onClick={(e) => this.handleTagRemoveButtonClick(tag)}
122123
>
123124
<img className='tag-removeButton-icon' src='../resources/icon/icon-x.svg' width='8px' />
124125
</button>

0 commit comments

Comments
 (0)