Open platform to collect and prioritize feedback
fix(ui): Truncates auto-generated title at newline The fix to strip markdown syntax from the auto-generated title prevented the title from being truncated at the first newline of the description. By moving plainText() to ShareFeedback.tsx we preserve the truncation
widal001ab8d60463ec2
diff --git a/public/components/common/form/CommentEditor.tsx b/public/components/common/form/CommentEditor.tsxindex 46d4cfb93..272437722 100644--- a/public/components/common/form/CommentEditor.tsx+++ b/public/components/common/form/CommentEditor.tsx@@ -10,7 +10,6 @@ import Paragraph from "@tiptap/extension-paragraph"import Text from "@tiptap/extension-text"import HardBreak from "@tiptap/extension-hard-break"import { i18n } from "@lingui/core"-import { plainText } from "@fider/services/markdown"import { useAllowedProtocols } from "@fider/hooks"import "./CommentEditor.scss"@@ -336,12 +335,9 @@ const Tiptap: React.FunctionComponent<CommentEditorProps> = (props) => {const updated = ({ editor }: { editor: Editor; transaction: any }): void => {// Get the current markdown contentconst markdown = isRawMarkdownMode ? editor.getText() : editor.storage.markdown.getMarkdown()- // In markdown mode, the tiptap markdown extension isn't loaded, which means editor.getText()- // includes markdown syntax, so we need to use plainText() to remove it.- const plainTextContent = plainText(editor.getText())- // Pass both markdown and plain text to parent- props.onChange && props.onChange(markdown, plainTextContent)+ // Pass markdown to parent (plain text will be generated in ShareFeedback if needed)+ props.onChange && props.onChange(markdown)// Track the current state of images in the document// This will also check for removed imagesdiff --git a/public/pages/Home/components/ShareFeedback.tsx b/public/pages/Home/components/ShareFeedback.tsxindex 2f928497a..7b453e532 100644--- a/public/pages/Home/components/ShareFeedback.tsx+++ b/public/pages/Home/components/ShareFeedback.tsx@@ -6,6 +6,7 @@ import { Modal, CloseIcon, Form, Button, Input, LegalFooter } from "@fider/compoimport { useFider } from "@fider/hooks"import { Trans } from "@lingui/react/macro"import { actions, Failure, querystring, classSet } from "@fider/services"+import { plainText } from "@fider/services/markdown"import { i18n } from "@lingui/core"import { Tag } from "@fider/models"import { SimilarPosts } from "../components/SimilarPosts"@@ -57,8 +58,6 @@ export const ShareFeedback: React.FC<ShareFeedbackProps> = (props) => {const canEditTags = fider.settings.postWithTags && props.tags.length > 0const [title, setTitle] = useState(getCachedTitle())const [description, setDescription] = useState(getCachedDescription())- // Add state for plain text version of description- const [descriptionPlainText, setDescriptionPlainText] = useState("")const { attachments, handleImageUploaded, getImageSrc, clearAttachments } = useAttachments({cacheKey: CACHE_KEYS.ATTACHMENT,useLocalStorage: true,@@ -108,17 +107,19 @@ export const ShareFeedback: React.FC<ShareFeedbackProps> = (props) => {useEffect(() => {if (!titleManuallyEdited && !isInitialMount) {- // Use plain text for title generation if available, otherwise fall back to description- const textToUse = descriptionPlainText || description-- let newlineIndex = Math.min(textToUse.indexOf("\n"), 80)+ // Find newline in the original markdown content for truncation+ let newlineIndex = Math.min(description.indexOf("\n"), 80)if (newlineIndex == -1) {newlineIndex = 80}- const autoTitle = textToUse.substring(0, newlineIndex)++ // Get the truncated markdown content and convert to plain text+ const truncatedMarkdown = description.substring(0, newlineIndex)+ const autoTitle = plainText(truncatedMarkdown)+handleTitleChange(autoTitle, false)}- }, [description, descriptionPlainText, titleManuallyEdited])+ }, [description, titleManuallyEdited])useEffect(() => {if (isOpen && editorRef.current) {@@ -156,7 +157,7 @@ export const ShareFeedback: React.FC<ShareFeedbackProps> = (props) => {setTags(newTags)}- const handleDescriptionChange = (value: string, plainText?: string) => {+ const handleDescriptionChange = (value: string) => {setCachedDescription(value)// If the description starts with an image attachment, we don't want to set it as the title@@ -165,11 +166,6 @@ export const ShareFeedback: React.FC<ShareFeedbackProps> = (props) => {}setDescription(value)-- // Store plain text version if provided- if (plainText !== undefined) {- setDescriptionPlainText(plainText)- }}const onSubmitFeedback = () => {