From 1c18184ef4fd3ddda089bd8d37a0f83bf5b47dbc Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 17 Dec 2022 17:25:04 +0800 Subject: [PATCH] Fix one-char space inserted when replying to own posts --- src/components/compose.jsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index c35d8913..aca29fde 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -93,11 +93,15 @@ function Compose({ replyToStatus.account.acct, ...replyToStatus.mentions.map((m) => m.acct), ]); - textareaRef.current.value = `${[...mentions] - .filter((m) => m !== currentAccountInfo.acct) // Excluding self - .map((m) => `@${m}`) - .join(' ')} `; - textareaRef.current.dispatchEvent(new Event('input')); + const allMentions = [...mentions].filter( + (m) => m !== currentAccountInfo.acct, + ); + if (allMentions.length > 0) { + textareaRef.current.value = `${allMentions + .map((m) => `@${m}`) + .join(' ')} `; + textareaRef.current.dispatchEvent(new Event('input')); + } textareaRef.current.focus(); } setVisibility(visibility);