Fix duplicate tags in TagDiscussionModal

Add an inclusion check for the tag itself as well as its parent before adding it to the list of selected tags.
This commit is contained in:
Alexander Skvortsov 2020-10-07 17:52:38 -04:00
parent bdb55e45c4
commit b64e5d0998

View File

@ -68,14 +68,13 @@ export default class TagDiscussionModal extends Modal {
// If this tag has a parent, we'll also need to add the parent tag to the // If this tag has a parent, we'll also need to add the parent tag to the
// selected list if it's not already in there. // selected list if it's not already in there.
const parent = tag.parent(); const parent = tag.parent();
if (parent) { if (parent && this.selected.indexOf(parent) === -1) {
const index = this.selected.indexOf(parent); this.selected.push(parent);
if (index === -1) {
this.selected.push(parent);
}
} }
this.selected.push(tag); if (this.selected.indexOf(tag) === -1) {
this.selected.push(tag);
}
} }
/** /**