Skip to content

Commit

Permalink
fix dirty form navigation blocker
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Sep 13, 2023
1 parent 14a65f9 commit 571e10f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion databox/client/src/api/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ export const attributeDefinitionNS = '/attribute-definitions';

export async function putAttributeDefinition(
id: string | undefined,
data: AttributeDefinition
data: Partial<AttributeDefinition>
): Promise<AttributeDefinition> {
delete data.workspace;

return ((await apiClient.put(`${attributeDefinitionNS}/${id}`, data)).data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ function Item({
control,
watch,
setValue,
reset,
formState: {errors, isDirty}
} = useForm<any>({
defaultValues: data,
});

React.useEffect(() => {
reset(data);
}, [data]);

useDirtyFormPrompt(isDirty);

const isPublic = watch('public');
Expand Down

0 comments on commit 571e10f

Please sign in to comment.