Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline commenting - Focus the reply field when clicking on the comment toolbar button #66905

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 47 additions & 39 deletions packages/editor/src/components/collab-sidebar/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ import CommentForm from './comment-form';
/**
* Renders the Comments component.
*
* @param {Object} props - The component props.
* @param {Array} props.threads - The array of comment threads.
* @param {Function} props.onEditComment - The function to handle comment editing.
* @param {Function} props.onAddReply - The function to add a reply to a comment.
* @param {Function} props.onCommentDelete - The function to delete a comment.
* @param {Function} props.onCommentResolve - The function to mark a comment as resolved.
* @param {Object} props - The component props.
* @param {Array} props.threads - The array of comment threads.
* @param {Function} props.onEditComment - The function to handle comment editing.
* @param {Function} props.onAddReply - The function to add a reply to a comment.
* @param {Function} props.onCommentDelete - The function to delete a comment.
* @param {Function} props.onCommentResolve - The function to mark a comment as resolved.
* @param {boolean} props.showCommentBoard - Whether to show the comment board.
* @param {Function} props.setShowCommentBoard - The function to set the comment board visibility.
* @return {JSX.Element} The rendered Comments component.
*/
export function Comments( {
Expand All @@ -43,6 +45,8 @@ export function Comments( {
onAddReply,
onCommentDelete,
onCommentResolve,
showCommentBoard,
setShowCommentBoard,
} ) {
const [ actionState, setActionState ] = useState( false );
const [ isConfirmDialogOpen, setIsConfirmDialogOpen ] = useState( false );
Expand Down Expand Up @@ -218,42 +222,46 @@ export function Comments( {
/>
</VStack>
) ) }
{ 'reply' === actionState?.action &&
thread.id === actionState?.id && (
{ ( ( showCommentBoard &&
blockCommentId === thread.id ) ||
( 'reply' === actionState?.action &&
thread.id === actionState?.id ) ) && (
<VStack
className="editor-collab-sidebar-panel__child-thread"
spacing="2"
>
<HStack
alignment="left"
spacing="3"
justify="flex-start"
>
<CommentAuthorInfo />
</HStack>
<VStack
className="editor-collab-sidebar-panel__child-thread"
spacing="2"
spacing="3"
className="editor-collab-sidebar-panel__comment-field"
>
<HStack
alignment="left"
spacing="3"
justify="flex-start"
>
<CommentAuthorInfo />
</HStack>
<VStack
spacing="3"
className="editor-collab-sidebar-panel__comment-field"
>
<CommentForm
onSubmit={ ( inputComment ) => {
onAddReply(
inputComment,
thread.id
);
setActionState( false );
} }
onCancel={ () =>
setActionState( false )
}
submitButtonText={ _x(
'Reply',
'Add reply comment'
) }
/>
</VStack>
<CommentForm
onSubmit={ ( inputComment ) => {
onAddReply(
inputComment,
thread.id
);
setActionState( false );
setShowCommentBoard( false );
} }
onCancel={ () => {
setActionState( false );
setShowCommentBoard( false );
} }
submitButtonText={ _x(
'Reply',
'Add reply comment'
) }
/>
</VStack>
) }
</VStack>
) }
</VStack>
) ) }
</>
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ function CollabSidebarContent( { showCommentBoard, setShowCommentBoard } ) {
onAddReply={ addNewComment }
onCommentDelete={ onCommentDelete }
onCommentResolve={ onCommentResolve }
showCommentBoard={ showCommentBoard }
setShowCommentBoard={ setShowCommentBoard }
/>
</div>
);
Expand Down
Loading