From d267f731d3b9a02f0df16b8fdb5ea87b6db24a32 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sun, 7 Jun 2026 12:47:54 +0200 Subject: [PATCH] bug-fix --- .../NoteOptions/EditOrCloneEventDialog.tsx | 3 +- src/components/PostEditor/PostContent.tsx | 31 ++++++++++--------- .../PostEditor/PostTextarea/index.tsx | 7 ++++- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/components/NoteOptions/EditOrCloneEventDialog.tsx b/src/components/NoteOptions/EditOrCloneEventDialog.tsx index 3ec9e3b7..9216fd3b 100644 --- a/src/components/NoteOptions/EditOrCloneEventDialog.tsx +++ b/src/components/NoteOptions/EditOrCloneEventDialog.tsx @@ -377,7 +377,8 @@ export default function EditOrCloneEventDialog(props: EditOrCloneEventDialogProp const k = isCreate ? parsedCreateKind! : sourceEvent!.kind const key = advancedLabDraftPersistenceKey const saved = key ? postEditorCache.getAdvancedLabDraft(key) : undefined - if (saved && saved.kind === k) { + const useSavedLabBody = !content.trim() && saved && saved.kind === k + if (useSavedLabBody) { setAdvancedLabInitial({ kind: saved.kind, content: saved.content, diff --git a/src/components/PostEditor/PostContent.tsx b/src/components/PostEditor/PostContent.tsx index f51ebffa..5c1f16ed 100644 --- a/src/components/PostEditor/PostContent.tsx +++ b/src/components/PostEditor/PostContent.tsx @@ -1361,21 +1361,22 @@ export default function PostContent({ const body = textareaRef.current?.getText() ?? text const cleanedText = rewritePlainTextHttpUrls(body) let d = await finalizeDraftEvent(cleanedText) - const labKey = advancedLabPersistenceKey - const saved = postEditorCache.getAdvancedLabDraft(labKey) - if (saved && saved.kind === d.kind) { - setAdvancedLabInitial({ - kind: saved.kind, - content: saved.content, - tags: stripImwaldAttributionTags(saved.tags).map((row: string[]) => [...row]) - }) - } else { - setAdvancedLabInitial({ - kind: d.kind, - content: d.content, - tags: stripImwaldAttributionTags(d.tags ?? []).map((row: string[]) => [...row]) - }) - } + const saved = postEditorCache.getAdvancedLabDraft(advancedLabPersistenceKey) + // Prefer live composer text; only restore a persisted lab body when the composer is empty. + const useSavedLabBody = !d.content.trim() && saved && saved.kind === d.kind + setAdvancedLabInitial( + useSavedLabBody + ? { + kind: saved.kind, + content: saved.content, + tags: stripImwaldAttributionTags(saved.tags).map((row: string[]) => [...row]) + } + : { + kind: d.kind, + content: d.content, + tags: stripImwaldAttributionTags(d.tags ?? []).map((row: string[]) => [...row]) + } + ) setAdvancedLabOpen(true) } catch (e) { toast.error(e instanceof Error ? e.message : String(e)) diff --git a/src/components/PostEditor/PostTextarea/index.tsx b/src/components/PostEditor/PostTextarea/index.tsx index 5e74b739..034ac8e9 100644 --- a/src/components/PostEditor/PostTextarea/index.tsx +++ b/src/components/PostEditor/PostTextarea/index.tsx @@ -1,3 +1,4 @@ +import { ExtendedKind } from '@/constants' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { parseEditorJsonToText, plainTextToTipTapDoc } from '@/lib/tiptap' import { cn } from '@/lib/utils' @@ -159,7 +160,11 @@ const PostTextarea = forwardRef< }, [setText, text]) const previewSurfaceClass = cn( - isSmallScreen ? 'min-h-[min(36dvh,17rem)]' : 'min-h-52' + kind === ExtendedKind.POLL + ? 'min-h-20' + : isSmallScreen + ? 'min-h-[min(36dvh,17rem)]' + : 'min-h-52' ) const kindDescription = useMemo(() => getKindDescription(kind), [kind])