fix: multi-text-input not saving on blur (#2128)

This commit is contained in:
Meier Lukas
2025-01-26 21:26:08 +01:00
committed by GitHub
parent b38de29a88
commit dd2ca13004

View File

@@ -49,6 +49,17 @@ export const WidgetMultiTextInput = ({ property, kind, options }: CommonWidgetIn
return null; return null;
}, [currentValidationResult, search]); }, [currentValidationResult, search]);
const handleAddSearch = () => {
if (search.length === 0 || !currentValidationResult.success) {
return;
}
if (values.includes(search)) {
return;
}
onChange([...values, search]);
setSearch("");
};
return ( return (
<Combobox store={combobox}> <Combobox store={combobox}>
<Combobox.DropdownTarget> <Combobox.DropdownTarget>
@@ -68,7 +79,10 @@ export const WidgetMultiTextInput = ({ property, kind, options }: CommonWidgetIn
<Combobox.EventsTarget> <Combobox.EventsTarget>
<PillsInput.Field <PillsInput.Field
onFocus={() => combobox.openDropdown()} onFocus={() => combobox.openDropdown()}
onBlur={() => combobox.closeDropdown()} onBlur={() => {
handleAddSearch();
combobox.closeDropdown();
}}
value={search} value={search}
placeholder={tCommon("multiText.placeholder")} placeholder={tCommon("multiText.placeholder")}
onChange={(event) => { onChange={(event) => {
@@ -81,14 +95,7 @@ export const WidgetMultiTextInput = ({ property, kind, options }: CommonWidgetIn
onChange(values.slice(0, -1)); onChange(values.slice(0, -1));
} else if (event.key === "Enter") { } else if (event.key === "Enter") {
event.preventDefault(); event.preventDefault();
if (search.length === 0 || !currentValidationResult.success) { handleAddSearch();
return;
}
if (values.includes(search)) {
return;
}
onChange([...values, search]);
setSearch("");
} }
}} }}
/> />