From 3039fc3d5929fc8e3746dccd5561bcca21f282ab Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Wed, 5 Jun 2024 08:47:50 +0200 Subject: [PATCH] fix: trying to create a tag that's too short gives errors (#7269) 1. Only suggest to create a tag value if the input is more than two characters after trimming. 2. Ignore trailing and leading whitespace when considering which autocomplete options to show --- .../FeatureOverview/ManageTagsDialog/TagsInput.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/TagsInput.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/TagsInput.tsx index a50336bbbc..8c7b54610a 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/TagsInput.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/ManageTagsDialog/TagsInput.tsx @@ -90,14 +90,19 @@ export const TagsInput = ({ options: TagOption[], params: FilterOptionsState, ) => { - const filtered = filter(options, params); + const inputValue = params.inputValue.trim(); + + const filtered = filter(options, { + ...params, + inputValue, + }); - const { inputValue } = params; // Suggest the creation of a new value const isExisting = options.some( (option) => inputValue === option.title, ); - if (inputValue !== '' && !isExisting) { + + if (inputValue.length >= 2 && !isExisting) { filtered.push({ inputValue, title: `Create new value "${inputValue}"`,