Merge pull request #2612 from lbryio/tags
fix: prevent duplicate tags on publish form
This commit is contained in:
commit
3447909c23
2 changed files with 9 additions and 2 deletions
|
@ -136,7 +136,14 @@ function PublishForm(props: Props) {
|
||||||
suggestMature
|
suggestMature
|
||||||
help={__('The better your tags are, the easier it will be for people to discover your content.')}
|
help={__('The better your tags are, the easier it will be for people to discover your content.')}
|
||||||
empty={__('No tags added')}
|
empty={__('No tags added')}
|
||||||
onSelect={tag => updatePublishForm({ tags: [...tags, tag] })}
|
onSelect={newTag => {
|
||||||
|
if (!tags.map(savedTag => savedTag.name).includes(newTag.name)) {
|
||||||
|
updatePublishForm({ tags: [...tags, newTag] });
|
||||||
|
} else {
|
||||||
|
// If it already exists and the user types it in, remove it
|
||||||
|
updatePublishForm({ tags: tags.filter(tag => tag.name !== newTag.name) });
|
||||||
|
}
|
||||||
|
}}
|
||||||
onRemove={clickedTag => {
|
onRemove={clickedTag => {
|
||||||
const newTags = tags.slice().filter(tag => tag.name !== clickedTag.name);
|
const newTags = tags.slice().filter(tag => tag.name !== clickedTag.name);
|
||||||
updatePublishForm({ tags: newTags });
|
updatePublishForm({ tags: newTags });
|
||||||
|
|
Loading…
Reference in a new issue