fix tags selection on channel edit page

This commit is contained in:
zxawry 2019-11-14 16:43:19 +00:00 committed by Sean Yesmunt
parent 59e8d693de
commit aa69b227bd

View file

@ -181,13 +181,15 @@ function ChannelForm(props: Props) {
help={__('The better your tags are, the easier it will be for people to discover your channel.')} help={__('The better your tags are, the easier it will be for people to discover your channel.')}
empty={__('No tags added')} empty={__('No tags added')}
placeholder={__('Add a tag')} placeholder={__('Add a tag')}
onSelect={newTag => { onSelect={newTags => {
if (!params.tags.map(savedTag => savedTag.name).includes(newTag.name)) { newTags.forEach(newTag => {
setParams({ ...params, tags: [...params.tags, newTag] }); if (!params.tags.map(savedTag => savedTag.name).includes(newTag.name)) {
} else { setParams({ ...params, tags: [...params.tags, newTag] });
// If it already exists and the user types it in, remove it } else {
setParams({ ...params, tags: params.tags.filter(tag => tag.name !== newTag.name) }); // If it already exists and the user types it in, remove it
} setParams({ ...params, tags: params.tags.filter(tag => tag.name !== newTag.name) });
}
});
}} }}
onRemove={clickedTag => { onRemove={clickedTag => {
const newTags = params.tags.slice().filter(tag => tag.name !== clickedTag.name); const newTags = params.tags.slice().filter(tag => tag.name !== clickedTag.name);