Skip to content

Commit 0b964f6

Browse files
set sub type id to undefined on type change (#1330)
Co-authored-by: Tom Chapman <tchapman000@gmail.com>
1 parent 39e18d5 commit 0b964f6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

epictrack-web/src/components/project/ProjectForm.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export default function ProjectForm({ ...props }) {
8686
control,
8787
formState: { errors },
8888
reset,
89+
setValue,
8990
} = methods;
9091
const formValues = useWatch({ control });
9192

@@ -147,6 +148,10 @@ export default function ProjectForm({ ...props }) {
147148
Promise.all(promises);
148149
}, []);
149150

151+
const typeChange = () => {
152+
setValue("sub_type_id", undefined);
153+
};
154+
150155
const onSubmitHandler = async (data: any) => {
151156
ctx.onSave(data, () => {
152157
reset();
@@ -241,6 +246,7 @@ export default function ProjectForm({ ...props }) {
241246
<Grid item xs={6}>
242247
<ETFormLabel required>Type</ETFormLabel>
243248
<ControlledSelectV2
249+
onHandleChange={typeChange}
244250
placeholder="Select"
245251
key={`type_select_${formValues.type_id}`}
246252
helperText={errors?.type_id?.message?.toString()}

0 commit comments

Comments
 (0)