From 20230d147a02fefa2df7500bf33ab5396459b70e Mon Sep 17 00:00:00 2001 From: Suemor Date: Wed, 3 May 2023 19:54:30 +0800 Subject: [PATCH] feat: disable button when comments have not been changed (#477) --- src/components/common/CommentInput.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/common/CommentInput.tsx b/src/components/common/CommentInput.tsx index 8427f6b2..d6d6a397 100644 --- a/src/components/common/CommentInput.tsx +++ b/src/components/common/CommentInput.tsx @@ -41,6 +41,8 @@ export const CommentInput: React.FC<{ }, }) + const inputContent = form.watch("content").trim() + const handleSubmit = form.handleSubmit(async (values) => { if (characterId && noteId) { if (comment) { @@ -122,7 +124,9 @@ export const CommentInput: React.FC<{ type="submit" isLoading={commentPage.isLoading || updateComment.isLoading} isDisabled={ - !!account?.character && form.watch("content").trim().length === 0 + !!account?.character && + (!inputContent || + inputContent === comment?.metadata?.content?.content) } > {t(