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