From 51ef3b16732366687674a9300a2055e873c1e829 Mon Sep 17 00:00:00 2001 From: akasunil Date: Mon, 4 Nov 2024 18:58:07 +0530 Subject: [PATCH] Cleanup and error fix --- .../components/collab-sidebar/add-comment.js | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/editor/src/components/collab-sidebar/add-comment.js b/packages/editor/src/components/collab-sidebar/add-comment.js index f8a79fdde9a673..fce47e821e2065 100644 --- a/packages/editor/src/components/collab-sidebar/add-comment.js +++ b/packages/editor/src/components/collab-sidebar/add-comment.js @@ -3,7 +3,6 @@ */ import { _x } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; -import { useState, useEffect } from '@wordpress/element'; import { __experimentalHStack as HStack, __experimentalVStack as VStack, @@ -30,9 +29,6 @@ export function AddComment( { showCommentBoard, setShowCommentBoard, } ) { - // State to manage the comment thread. - const [ inputComment, setInputComment ] = useState( '' ); - const { clientId, blockCommentId } = useSelect( ( select ) => { const { getSelectedBlock } = select( blockEditorStore ); const selectedBlock = getSelectedBlock(); @@ -42,15 +38,6 @@ export function AddComment( { }; } ); - useEffect( () => { - setInputComment( '' ); - }, [ clientId ] ); - - const handleCancel = () => { - setShowCommentBoard( false ); - setInputComment( '' ); - }; - if ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) { return null; } @@ -64,11 +51,12 @@ export function AddComment( { { + onSubmit={ ( inputComment ) => { onSubmit( inputComment ); - setInputComment( '' ); } } - onCancel={ handleCancel } + onCancel={ () => { + setShowCommentBoard( false ); + } } submitButtonText={ _x( 'Comment', 'Add comment button' ) } />