mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-11 02:37:22 +03:00
Ensured TagsSelector does not allow duplicated tags, and allows adding multiple coma-separated tags at once
This commit is contained in:
parent
cbe5f98aa3
commit
b8a7dccf92
1 changed files with 6 additions and 1 deletions
|
@ -44,13 +44,18 @@ const TagsSelector = (colorGenerator: ColorGenerator) => (
|
|||
addOnBlur
|
||||
placeholderText={placeholder}
|
||||
minQueryLength={1}
|
||||
delimiters={[ 'Enter', 'Tab', ',' ]}
|
||||
onDelete={(removedTagIndex) => {
|
||||
const tagsCopy = [ ...selectedTags ];
|
||||
|
||||
tagsCopy.splice(removedTagIndex, 1);
|
||||
onChange(tagsCopy);
|
||||
}}
|
||||
onAddition={({ name: newTag }) => onChange([ ...selectedTags, newTag.toLowerCase() ])}
|
||||
onAddition={({ name: newTag }) => onChange(
|
||||
// * Avoid duplicated tags (thanks to the Set),
|
||||
// * Split any of the new tags by comma, allowing to paste multiple comma-separated tags at once.
|
||||
[ ...new Set([ ...selectedTags, ...newTag.toLowerCase().split(',') ]) ],
|
||||
)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue