Skip to content

Commit

Permalink
Cleanup and error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
akasunil committed Nov 4, 2024
1 parent bcd082d commit 51ef3b1
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions packages/editor/src/components/collab-sidebar/add-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
Expand All @@ -42,15 +38,6 @@ export function AddComment( {
};
} );

useEffect( () => {
setInputComment( '' );
}, [ clientId ] );

const handleCancel = () => {
setShowCommentBoard( false );
setInputComment( '' );
};

if ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {
return null;
}
Expand All @@ -64,11 +51,12 @@ export function AddComment( {
<CommentAuthorInfo />
</HStack>
<CommentForm
onSubmit={ () => {
onSubmit={ ( inputComment ) => {
onSubmit( inputComment );
setInputComment( '' );
} }
onCancel={ handleCancel }
onCancel={ () => {
setShowCommentBoard( false );
} }
submitButtonText={ _x( 'Comment', 'Add comment button' ) }
/>
</VStack>
Expand Down

0 comments on commit 51ef3b1

Please sign in to comment.