1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

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
This commit is contained in:
Thomas Heartman 2024-06-05 08:47:50 +02:00 committed by GitHub
parent 2bad98a121
commit 3039fc3d59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -90,14 +90,19 @@ export const TagsInput = ({
options: TagOption[],
params: FilterOptionsState<TagOption>,
) => {
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}"`,