diff --git a/components/editor.tsx b/components/editor.tsx index 21f2bb6..445f25f 100644 --- a/components/editor.tsx +++ b/components/editor.tsx @@ -24,7 +24,7 @@ interface EditorProps { type FormData = z.infer export function Editor({ post }: EditorProps) { - const { register, handleSubmit } = useForm({ + const { register, handleSubmit, formState } = useForm({ resolver: zodResolver(postPatchSchema), }) const ref = React.useRef() @@ -84,6 +84,8 @@ export function Editor({ post }: EditorProps) { }, [isMounted, initializeEditor]) async function onSubmit(data: FormData) { + if (!formState.isDirty) return + setIsSaving(true) const blocks = await ref.current?.save() @@ -140,7 +142,7 @@ export function Editor({ post }: EditorProps) {