fix field dropdown on change

This commit is contained in:
rizky 2024-07-29 23:33:06 -07:00
parent 3b1e65607c
commit 1facc07784
4 changed files with 6 additions and 7 deletions

View File

@ -174,11 +174,6 @@ export const Form: FC<FMProps> = (props) => {
if (fm.status === "resizing") { if (fm.status === "resizing") {
fm.status = "ready"; fm.status = "ready";
} }
// useEffect(() => {
// setTimeout(() => {
// fm.render();
// }, 100);
// }, []);
return ( return (
<form <form
onSubmit={(e) => { onSubmit={(e) => {

View File

@ -34,6 +34,7 @@ export const Field: FC<FieldProp> = (arg) => {
fm.render(); fm.render();
} }
}, [fm.data[name]]); }, [fm.data[name]]);
if (field.status === "init" && !isEditor) return null; if (field.status === "init" && !isEditor) return null;
const errors = fm.error.get(name); const errors = fm.error.get(name);
const props = { ...arg.props }; const props = { ...arg.props };

View File

@ -56,6 +56,7 @@ export const TypeDropdown: FC<{
type: field.type, type: field.type,
}) })
: fm.data[field.name]; : fm.data[field.name];
if ( if (
field.type === "single-option" && field.type === "single-option" &&
!value && !value &&
@ -140,6 +141,8 @@ export const TypeDropdown: FC<{
}); });
} }
fm.data[field.name] = item?.value;
return item?.value || search; return item?.value || search;
}} }}
disabled={disabled} disabled={disabled}