From 21b6db3c376cff8c268e0efe94c7d0dbc449a459 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Fri, 7 Oct 2022 19:57:07 -0700 Subject: [PATCH] Clear autosave on submit post/market/comment --- web/components/comment-input.tsx | 2 +- web/components/create-post.tsx | 1 + web/components/editor.tsx | 2 +- web/pages/create.tsx | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/web/components/comment-input.tsx b/web/components/comment-input.tsx index 34553ca6..460fa438 100644 --- a/web/components/comment-input.tsx +++ b/web/components/comment-input.tsx @@ -88,7 +88,7 @@ export function CommentInputTextArea(props: { const submit = () => { submitComment() - editor?.commands?.clearContent() + editor?.commands?.clearContent(true) } useEffect(() => { diff --git a/web/components/create-post.tsx b/web/components/create-post.tsx index 28233b4d..cbc4c252 100644 --- a/web/components/create-post.tsx +++ b/web/components/create-post.tsx @@ -46,6 +46,7 @@ export function CreatePost(props: { group?: Group }) { return e }) if (result.post) { + editor.commands.clearContent(true) await Router.push(postPath(result.post.slug)) } } diff --git a/web/components/editor.tsx b/web/components/editor.tsx index 36978dc4..0c0c9af5 100644 --- a/web/components/editor.tsx +++ b/web/components/editor.tsx @@ -81,7 +81,7 @@ export function useTextEditor(props: { defaultValue?: Content disabled?: boolean simple?: boolean - key?: string // unique key for this text field for autosave + key?: string // unique key for autosave. If set, plz call `clearContent(true)` on submit to clear autosave }) { const { placeholder, max, defaultValue, disabled, simple, key } = props diff --git a/web/pages/create.tsx b/web/pages/create.tsx index 9ff9d8c9..b24a3ff9 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -269,6 +269,7 @@ export function NewContract(props: { selectedGroup: selectedGroup?.id, isFree: false, }) + editor?.commands.clearContent(true) await router.push(contractPath(result as Contract)) } catch (e) { console.error('error creating contract', e, (e as any).details)