From c1288ce4bb79ef7b45085113f7cc1f889cd97e6b Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Wed, 18 Sep 2024 23:24:10 -0500 Subject: [PATCH] Use index to find and remove tags Fixes issue in last commit, so removing a tag that has duplicate value of other tags only removes the correct one, not the others as well. --- client/homebrew/editor/tagInput/tagInput.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/homebrew/editor/tagInput/tagInput.jsx b/client/homebrew/editor/tagInput/tagInput.jsx index 03678961d..f72ec17cf 100644 --- a/client/homebrew/editor/tagInput/tagInput.jsx +++ b/client/homebrew/editor/tagInput/tagInput.jsx @@ -24,12 +24,12 @@ const TagInput = ({ unique = true, values = [], ...props }) => { - const submitTag = (newValue, originalValue) => { + const submitTag = (newValue, originalValue, index) => { setValueContext((prevContext) => { // remove existing tag if(newValue === null){ console.log('remove'); - return [...prevContext].filter((context)=>context.value !== originalValue); + return [...prevContext].filter((context, i)=>i !== index); } // add new tag if(originalValue === null){ @@ -63,7 +63,7 @@ const TagInput = ({ unique = true, values = [], ...props }) => { className='tag' onClick={() => editTag(context.value)}> {context.value} - + ); };