From a54adc1e4b9756dd9efc23b4c114516d5ebd697f Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Wed, 18 Sep 2024 23:39:26 -0500 Subject: [PATCH] Set new tag input to clear itself after submission Now whenever a new tag is submitted, the input element is cleared and ready for the next tag. Whitespace cleanup. --- client/homebrew/editor/tagInput/tagInput.jsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client/homebrew/editor/tagInput/tagInput.jsx b/client/homebrew/editor/tagInput/tagInput.jsx index f72ec17cf..625e89c36 100644 --- a/client/homebrew/editor/tagInput/tagInput.jsx +++ b/client/homebrew/editor/tagInput/tagInput.jsx @@ -16,19 +16,17 @@ const TagInput = ({ unique = true, values = [], ...props }) => { }) }; - const handleInputKeyDown = (evt, value) => { + const handleInputKeyDown = (evt, value, clear = false) => { if (evt.key === 'Enter') { submitTag(evt.target.value, value); - } + if(clear){ setTemporaryValue(''); } + }; }; - - const submitTag = (newValue, originalValue, index) => { setValueContext((prevContext) => { // remove existing tag if(newValue === null){ - console.log('remove'); return [...prevContext].filter((context, i)=>i !== index); } // add new tag @@ -90,7 +88,7 @@ const TagInput = ({ unique = true, values = [], ...props }) => { placeholder={props.placeholder} value={temporaryValue} onChange={(e) => setTemporaryValue(e.target.value)} - onKeyDown={(evt) => handleInputKeyDown(evt, null)} /> + onKeyDown={(evt) => handleInputKeyDown(evt, null, true)} /> );