diff --git a/src/components/TagInput.tsx b/src/components/TagInput.tsx index af2e82e5..fa73ae15 100644 --- a/src/components/TagInput.tsx +++ b/src/components/TagInput.tsx @@ -121,12 +121,12 @@ export default function TagInput({ case 'Enter': // Only trap focus if there are options to select // otherwise allow form to submit - if (optionsFiltered.length > 0) { + if (shouldShowMenu && optionsFiltered.length > 0) { e.stopImmediatePropagation(); e.preventDefault(); + addOption(optionsFiltered[selectedOptionIndex ?? 0].value); + setInputText(''); } - addOption(optionsFiltered[selectedOptionIndex ?? 0].value); - setInputText(''); break; case ',': addOption(inputText); @@ -181,6 +181,7 @@ export default function TagInput({ selectedOptionIndex, optionsFiltered, addOption, + shouldShowMenu, ]); return ( @@ -272,13 +273,7 @@ export default function TagInput({ {value} {annotation && - + {annotation} } )}