From d8cfb902a287fb968ce8d7ccb6ff79ad8c238cdd Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Fri, 5 Aug 2022 10:08:01 -0700 Subject: [PATCH] On reply, put space instead of \n after mention --- web/components/feed/feed-comments.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/components/feed/feed-comments.tsx b/web/components/feed/feed-comments.tsx index fd2dbde2..8c84039e 100644 --- a/web/components/feed/feed-comments.tsx +++ b/web/components/feed/feed-comments.tsx @@ -495,13 +495,17 @@ export function CommentInputTextArea(props: { }, }, }) - // insert at mention + // insert at mention and focus if (replyToUser) { - editor.commands.insertContentAt(0, { - type: 'mention', - attrs: { label: replyToUser.username, id: replyToUser.id }, - }) - editor.commands.focus() + editor + .chain() + .setContent({ + type: 'mention', + attrs: { label: replyToUser.username, id: replyToUser.id }, + }) + .insertContent(' ') + .focus() + .run() } // eslint-disable-next-line react-hooks/exhaustive-deps }, [editor])