This commit is contained in:
rizky 2024-07-30 02:26:24 -07:00
parent dc05e278c4
commit d1de16a753
1 changed files with 19 additions and 22 deletions

View File

@ -25,6 +25,7 @@ export const TypeDropdown: FC<{
: fm.data[field.name]; : fm.data[field.name];
useEffect(() => { useEffect(() => {
if (isEditor) return;
if (typeof arg.on_load === "function") { if (typeof arg.on_load === "function") {
const options = arg.on_load({ field }); const options = arg.on_load({ field });
if (options instanceof Promise) { if (options instanceof Promise) {
@ -57,26 +58,24 @@ export const TypeDropdown: FC<{
}) })
: fm.data[field.name]; : fm.data[field.name];
if ( if (field.type === "single-option") {
field.type === "single-option" && if (!value && local.options.length > 0) {
!value && arg.opt_set_value({
local.options.length > 0 fm,
) { name: field.name,
arg.opt_set_value({ type: field.type,
fm, options: local.options,
name: field.name, selected: [local.options[0]?.value],
type: field.type, });
options: local.options, } else if ( value) {
selected: [local.options[0]?.value], arg.opt_set_value({
}); fm,
} else if (field.type === "single-option" && value) { name: field.name,
arg.opt_set_value({ type: field.type,
fm, options: local.options,
name: field.name, selected: [value],
type: field.type, });
options: local.options, }
selected: [value],
});
} }
local.loaded = true; local.loaded = true;
@ -141,8 +140,6 @@ export const TypeDropdown: FC<{
}); });
} }
fm.data[field.name] = item?.value;
return item?.value || search; return item?.value || search;
}} }}
disabled={disabled} disabled={disabled}