Procházet zdrojové kódy

BugFix: do not set disabled

Yuki Takei před 2 roky
rodič
revize
024e153062

+ 2 - 7
apps/app/src/components/PageComment/CommentEditor.tsx

@@ -150,9 +150,7 @@ export const CommentEditor = (props: CommentEditorProps): JSX.Element => {
   }, [onCancelButtonClicked, initializeEditor]);
   }, [onCancelButtonClicked, initializeEditor]);
 
 
   const postCommentHandler = useCallback(async() => {
   const postCommentHandler = useCallback(async() => {
-    const commentBodyToPost = codeMirrorEditor?.getDoc();
-
-    if (commentBodyToPost == null || commentBodyToPost?.length === 0) return;
+    const commentBodyToPost = codeMirrorEditor?.getDoc() ?? '';
 
 
     try {
     try {
       if (currentCommentId != null) {
       if (currentCommentId != null) {
@@ -233,20 +231,17 @@ export const CommentEditor = (props: CommentEditorProps): JSX.Element => {
     </button>
     </button>
   ), [cancelButtonClickedHandler, t]);
   ), [cancelButtonClickedHandler, t]);
   const submitButton = useMemo(() => {
   const submitButton = useMemo(() => {
-    const commentBodyToPost = codeMirrorEditor?.getDoc() ?? '';
-
     return (
     return (
       <button
       <button
         type="button"
         type="button"
         data-testid="comment-submit-button"
         data-testid="comment-submit-button"
         className="btn btn-primary"
         className="btn btn-primary"
         onClick={postCommentHandler}
         onClick={postCommentHandler}
-        disabled={commentBodyToPost.length === 0}
       >
       >
         {t('page_comment.comment')}
         {t('page_comment.comment')}
       </button>
       </button>
     );
     );
-  }, [codeMirrorEditor, postCommentHandler, t]);
+  }, [postCommentHandler, t]);
 
 
   return (
   return (
     <CommentEditorLayout>
     <CommentEditorLayout>