fix: reset onclose

This commit is contained in:
hexastack 2025-02-06 11:50:31 +01:00
parent d563530ccf
commit 89d8fae613

View File

@ -110,12 +110,14 @@ export const ContentTypeDialog: FC<ContentTypeDialogProps> = ({
}, [open, reset]); }, [open, reset]);
useEffect(() => { useEffect(() => {
if (!open) return;
if (data) { if (data) {
reset({ reset({
name: data.name, name: data.name,
fields: data.fields || [], fields: data.fields?.length ? data.fields : FIELDS_FORM_DEFAULT_VALUES,
}); });
replace(data.fields || FIELDS_FORM_DEFAULT_VALUES); replace(data.fields?.length ? data.fields : FIELDS_FORM_DEFAULT_VALUES);
} else { } else {
reset({ name: "", fields: FIELDS_FORM_DEFAULT_VALUES }); reset({ name: "", fields: FIELDS_FORM_DEFAULT_VALUES });
replace(FIELDS_FORM_DEFAULT_VALUES); replace(FIELDS_FORM_DEFAULT_VALUES);
@ -173,7 +175,7 @@ export const ContentTypeDialog: FC<ContentTypeDialogProps> = ({
</ContentContainer> </ContentContainer>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<DialogButtons closeDialog={closeDialog} /> <DialogButtons closeDialog={closeAndReset} />
</DialogActions> </DialogActions>
</form> </form>
</Dialog> </Dialog>