Skip to content

Commit 31184ec

Browse files
committed
fix(run-job): fix hydration issue with the options form
1 parent d591383 commit 31184ec

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

components/runCards/JobCard/JobModal.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getGetInstancesQueryKey, useCreateInstance } from "@squonk/data-manager
1010
import { useGetJob } from "@squonk/data-manager-client/job";
1111

1212
import { Box, Grid, TextField, Typography } from "@mui/material";
13-
import Form from "@rjsf/mui";
13+
import type { FormProps } from "@rjsf/core";
1414
import validator from "@rjsf/validator-ajv8";
1515
import { useQueryClient } from "@tanstack/react-query";
1616
import dynamic from "next/dynamic";
@@ -28,6 +28,11 @@ const JobInputFields = dynamic<JobInputFieldsProps>(
2828
{ loading: () => <CenterLoader /> },
2929
);
3030

31+
// this dynamic import is necessary to avoid hydration issues with the form
32+
const Form = dynamic<FormProps>(() => import("@rjsf/mui").then((mod) => mod.Form), {
33+
loading: () => <CenterLoader />,
34+
});
35+
3136
export type InputData = Record<string, string | string[] | undefined>;
3237

3338
interface JobSpecification {
@@ -161,14 +166,15 @@ export const JobModal = ({
161166
}
162167
};
163168

169+
const validateForm = formRef.current?.validateForm;
170+
164171
return (
165172
<ModalWrapper
166173
DialogProps={{ maxWidth: "md", fullWidth: true }}
167174
id={`job-${jobId}`}
168175
open={open}
169176
submitDisabled={
170-
(formRef.current?.validateForm() !== undefined && !formRef.current?.validateForm()) ||
171-
!inputsValid
177+
(validateForm && validateForm() !== undefined && validateForm()) || !inputsValid
172178
}
173179
submitText="Run"
174180
title={job?.name ?? "Run Job"}

0 commit comments

Comments
 (0)