Skip to content

Commit

Permalink
update new option func
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 committed Nov 14, 2024
1 parent 5c534d1 commit 5fad0eb
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function SelectInfiniteScroll({
const updateNewOption = (newOptions, query) => {
if (props.creatable && !isEmpty(query)) {
const isValueExist = props.value?.some(v => v[labelKey] === query);
const isOptionExist = newOptions.some((option) => option.label === query);
const isOptionExist = newOptions.some((o) => o[labelKey] === query);

// Add new option if it doesn't exist and `creatable` is enabled
if (!isValueExist && !isOptionExist) {
Expand All @@ -56,6 +56,7 @@ function SelectInfiniteScroll({
result: { [valueKey]: query, [labelKey]: query }
}].concat(newOptions);
}
return newOptions;
}
return newOptions;
};
Expand Down

0 comments on commit 5fad0eb

Please sign in to comment.