mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-07 01:16:28 +02: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:
parent
2bad98a121
commit
3039fc3d59
@ -90,14 +90,19 @@ export const TagsInput = ({
|
|||||||
options: TagOption[],
|
options: TagOption[],
|
||||||
params: FilterOptionsState<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
|
// Suggest the creation of a new value
|
||||||
const isExisting = options.some(
|
const isExisting = options.some(
|
||||||
(option) => inputValue === option.title,
|
(option) => inputValue === option.title,
|
||||||
);
|
);
|
||||||
if (inputValue !== '' && !isExisting) {
|
|
||||||
|
if (inputValue.length >= 2 && !isExisting) {
|
||||||
filtered.push({
|
filtered.push({
|
||||||
inputValue,
|
inputValue,
|
||||||
title: `Create new value "${inputValue}"`,
|
title: `Create new value "${inputValue}"`,
|
||||||
|
Loading…
Reference in New Issue
Block a user