diff --git a/packages/client/components/DiscussionThreadInput.tsx b/packages/client/components/DiscussionThreadInput.tsx index 7690b39c11c..c4092107d71 100644 --- a/packages/client/components/DiscussionThreadInput.tsx +++ b/packages/client/components/DiscussionThreadInput.tsx @@ -259,7 +259,8 @@ const DiscussionThreadInput = (props: Props) => { const inputBottomRef = useRef(null) useEffect(() => { containerRef.current?.scrollIntoView({behavior: 'smooth', block: 'center'}) - }, []) + editor?.commands.focus('end') + }, [discussionId]) const containerRef = useRef(null) useClickAway(containerRef, clearReplyingTo) if (!editor) return null @@ -285,7 +286,7 @@ const DiscussionThreadInput = (props: Props) => { {isActionsContainerVisible && ( -
+
{allowTasks && } {allowPolls && }
diff --git a/packages/client/hooks/useTipTapCommentEditor.ts b/packages/client/hooks/useTipTapCommentEditor.ts index f3ad1df916e..b193ae8f132 100644 --- a/packages/client/hooks/useTipTapCommentEditor.ts +++ b/packages/client/hooks/useTipTapCommentEditor.ts @@ -76,11 +76,7 @@ export const useTipTapCommentEditor = ( }) ].filter(isValid), editable: !readOnly, - autofocus: true, - onCreate: ({editor}) => { - // Focus the editor and move the cursor to the end of the content - editor.commands.focus('end') - } + autofocus: true }, [readOnly] ) diff --git a/packages/client/mutations/UpdateTaskMutation.ts b/packages/client/mutations/UpdateTaskMutation.ts index e982862a54d..37b0b9c12ea 100644 --- a/packages/client/mutations/UpdateTaskMutation.ts +++ b/packages/client/mutations/UpdateTaskMutation.ts @@ -13,7 +13,6 @@ import { SharedUpdater, StandardMutation } from '../types/relayMutations' -import updateProxyRecord from '../utils/relay/updateProxyRecord' import handleAddNotifications from './handlers/handleAddNotifications' import handleRemoveTasks from './handlers/handleRemoveTasks' import handleUpsertTasks from './handlers/handleUpsertTasks' @@ -107,23 +106,18 @@ const UpdateTaskMutation: StandardMutation { - const {id, content, userId} = updatedTask + const {id, content, userId, status, sortOrder} = updatedTask const task = store.get(id) if (!task) return - const now = new Date() - const optimisticTask = { - // do not update content because that will cause the editor to rebuild itself - // we only want a rebuild if someone else changes the content - id, - userId, - updatedAt: now.toJSON() - } - updateProxyRecord(task, optimisticTask) + status && task.setValue(status, 'status') + sortOrder && task.setValue(sortOrder, 'sortOrder') if (userId) { task.setValue(userId, 'userId') task.setLinkedRecord(store.get(userId)!, 'user') } if (content) { + // do not update content because that will cause the editor to rebuild itself + // we only want a rebuild if someone else changes the content const contentJSON = JSON.parse(content) const nextTags = getTagsFromTipTapTask(contentJSON) task.setValue(nextTags, 'tags') diff --git a/packages/server/graphql/mutations/helpers/addAIGeneratedContentToThreads.ts b/packages/server/graphql/mutations/helpers/addAIGeneratedContentToThreads.ts index 16b91ea61ae..d03ddea860c 100644 --- a/packages/server/graphql/mutations/helpers/addAIGeneratedContentToThreads.ts +++ b/packages/server/graphql/mutations/helpers/addAIGeneratedContentToThreads.ts @@ -11,11 +11,11 @@ import {DataLoaderWorker} from '../../graphql' export const buildCommentContentBlock = ( title: string, - content: string, + contentHTML: string, explainerText?: string ) => { const explainerBlock = explainerText ? `${explainerText}
` : '' - const html = `${explainerBlock}

${title}

${content}

` + const html = `${explainerBlock}

${title}

${contentHTML}` return generateJSON(html, serverTipTapExtensions) as JSONContent } @@ -42,7 +42,10 @@ const addAIGeneratedContentToThreads = async ( if (group.discussionPromptQuestion) { const topicSummaryComment = createAIComment( discussionId, - buildCommentContentBlock('🤖 Discussion Question', group.discussionPromptQuestion), + buildCommentContentBlock( + '🤖 Discussion Question', + `

${group.discussionPromptQuestion}

` + ), 1 ) comments.push(topicSummaryComment)