diff --git a/packages/widgets/src/_inputs/widget-multi-text-input.tsx b/packages/widgets/src/_inputs/widget-multi-text-input.tsx index 9d1e9113f..864f200b5 100644 --- a/packages/widgets/src/_inputs/widget-multi-text-input.tsx +++ b/packages/widgets/src/_inputs/widget-multi-text-input.tsx @@ -49,6 +49,17 @@ export const WidgetMultiTextInput = ({ property, kind, options }: CommonWidgetIn return null; }, [currentValidationResult, search]); + const handleAddSearch = () => { + if (search.length === 0 || !currentValidationResult.success) { + return; + } + if (values.includes(search)) { + return; + } + onChange([...values, search]); + setSearch(""); + }; + return ( @@ -68,7 +79,10 @@ export const WidgetMultiTextInput = ({ property, kind, options }: CommonWidgetIn combobox.openDropdown()} - onBlur={() => combobox.closeDropdown()} + onBlur={() => { + handleAddSearch(); + combobox.closeDropdown(); + }} value={search} placeholder={tCommon("multiText.placeholder")} onChange={(event) => { @@ -81,14 +95,7 @@ export const WidgetMultiTextInput = ({ property, kind, options }: CommonWidgetIn onChange(values.slice(0, -1)); } else if (event.key === "Enter") { event.preventDefault(); - if (search.length === 0 || !currentValidationResult.success) { - return; - } - if (values.includes(search)) { - return; - } - onChange([...values, search]); - setSearch(""); + handleAddSearch(); } }} />