Tatiana Inama 6 лет назад
Родитель
Сommit
747f2b78a3
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      recipes/src/components/TagInput/index.tsx

+ 6 - 2
recipes/src/components/TagInput/index.tsx

@@ -35,6 +35,10 @@ export const TagInput:FunctionComponent<TagInputProps> = ({ label, onNewTag, tag
     }
     }
   }
   }
 
 
+  const removeTag = (tag: string) => {
+    updateTags(tags.filter(t => t !== tag))
+  }
+
   return (
   return (
     <div className="cbk-tag-input">
     <div className="cbk-tag-input">
       <Input
       <Input
@@ -44,16 +48,16 @@ export const TagInput:FunctionComponent<TagInputProps> = ({ label, onNewTag, tag
         onKeyDown={handleKeyDown}
         onKeyDown={handleKeyDown}
       />
       />
       <ChipSet
       <ChipSet
-        // updateChips={(chips) => updateTags(chips.map(chip => chip.label || ''))}
       >
       >
         {tags && tags.map((tag) => {
         {tags && tags.map((tag) => {
           const id = mkTagId(tag);
           const id = mkTagId(tag);
           return (
           return (
             <Chip
             <Chip
-              id={id}
+              id={tag}
               key={id}
               key={id}
               label={tag}
               label={tag}
               trailingIcon="close"
               trailingIcon="close"
+              onRemove={(evt) => { removeTag(evt.detail.chipId) }}
             />
             />
           )
           )
         }
         }