diff --git a/src/Components/Inputs/TextEditor/SaveModule.tsx b/src/Components/Inputs/TextEditor/SaveModule.tsx index 76b910f..ea9186a 100644 --- a/src/Components/Inputs/TextEditor/SaveModule.tsx +++ b/src/Components/Inputs/TextEditor/SaveModule.tsx @@ -1,6 +1,6 @@ +import { useDebouncedCallback } from '@react-hookz/web'; import { useHelpers, useRemirrorContext } from '@remirror/react'; import { Control, useController } from 'react-hook-form'; -import { useDebouncedCallback } from '@react-hookz/web'; interface Props { control?: Control, @@ -17,6 +17,7 @@ export default function SaveModule(props: Props) { const { getMarkdown } = useHelpers(); const changeCallback = useDebouncedCallback(ctx => { + const { state } = ctx; const md = getMarkdown(state); onChange(md); @@ -24,7 +25,6 @@ export default function SaveModule(props: Props) { useRemirrorContext(changeCallback) - // useEvent('focus', () => onBlur()) return <> } diff --git a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx index d836411..3dcb55b 100644 --- a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx +++ b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx @@ -90,15 +90,17 @@ export default function StoryForm() { const clickPreview = async () => { const isValid = await trigger(); - const data = getValues() if (isValid) { + const data = getValues() dispatch(stageStory(data)) navigate('/blog/preview-post/Story') + } else { + clickSubmit(); // I'm doing this so that the react-hook-form attaches onChange listener to inputs validation } } - const onSubmit: SubmitHandler = data => { + const clickSubmit = handleSubmit(data => { setLoading(true); createStory({ variables: { @@ -111,14 +113,15 @@ export default function StoryForm() { }, } }) - } + }) + const isUpdating = story?.id; return (