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:
parent
2bad98a121
commit
3039fc3d59
@ -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}"`,
|
||||
|
Loading…
Reference in New Issue
Block a user