From 2dabd3b8044752c315c521484b2c37e509726b2c Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Jan 2026 11:52:09 +0000 Subject: [PATCH] fix(post): preserve content when signing or publishing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Critical fix: Don't clear editor content until publish succeeds. **The Problem:** - RichEditor automatically cleared content on submit - Content was wiped immediately when clicking "Publish" - User lost their content before knowing if publish succeeded **The Solution:** - Remove automatic `clearContent()` from RichEditor's handleSubmit - Let PostViewer control when to clear the editor - Only clear editor after successful publish (successCount > 0) **User Experience Now:** - Click "Publish" → content stays visible while publishing - Publishing succeeds → content clears, show preview - Publishing fails → content stays, user can edit and retry - User rejects signing → content stays, can try again No more losing your post to a rejected signature or failed publish! --- src/components/PostViewer.tsx | 3 +++ src/components/editor/RichEditor.tsx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/PostViewer.tsx b/src/components/PostViewer.tsx index 42e32da..449f309 100644 --- a/src/components/PostViewer.tsx +++ b/src/components/PostViewer.tsx @@ -503,6 +503,9 @@ export function PostViewer({ windowId }: PostViewerProps = {}) { localStorage.removeItem(draftKey); } + // Clear editor content + editorRef.current?.clear(); + // Show published preview setShowPublishedPreview(true); diff --git a/src/components/editor/RichEditor.tsx b/src/components/editor/RichEditor.tsx index 6a3c8e4..acb5f23 100644 --- a/src/components/editor/RichEditor.tsx +++ b/src/components/editor/RichEditor.tsx @@ -402,7 +402,7 @@ export const RichEditor = forwardRef( serialized.eventRefs, serialized.addressRefs, ); - editorInstance.commands.clearContent(); + // Don't clear content here - let the parent component decide when to clear } }, [onSubmit],