Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e34c8c2
Collab Sidebar: Replace AddCommentToolbarButton with CommentAvatarInd…
yashjawale Aug 20, 2025
1f2a1db
refactor: use threadParticipants and enhance avatar styling for origi…
yashjawale Aug 20, 2025
73400a9
refactor: simplify comment avatar styling and improve background colo…
yashjawale Aug 20, 2025
d8cf981
refactor: update comment avatar styles to use border colors instead o…
yashjawale Aug 21, 2025
2e82c39
refactor: update comment resolution logic and simplify unresolved cou…
yashjawale Aug 21, 2025
2520dfd
refactor: filter out trashed comments in thread participant retrieval
yashjawale Aug 21, 2025
b286b3f
fix: handle case of 100+ comments
yashjawale Aug 29, 2025
58e11a8
refactor: update method for retrieving total pages of comments
yashjawale Aug 29, 2025
db5c16c
fix: style overflow indicator for longer text
yashjawale Aug 29, 2025
d9bf2ae
fix: sentence comments end with period
yashjawale Aug 29, 2025
d46bbae
fix: handle case where main comment is not found in thread
yashjawale Aug 29, 2025
e9cc58e
refactor: remove unused AddCommentToolbarButton component
yashjawale Aug 29, 2025
970dda7
fix: remove title attribute from avatar
yashjawale Sep 11, 2025
ff766e4
fix: overflowText i18n
yashjawale Sep 11, 2025
9f5f11a
fix: overflowTitle i18n
yashjawale Sep 11, 2025
237d7aa
fix: use SCSS variables in styles
yashjawale Sep 11, 2025
0425317
fix: remove unused `all-resolved` class
yashjawale Sep 11, 2025
b9defa9
fix: comment-indicator-toolbar.js syntax
yashjawale Sep 11, 2025
342f655
style: fix style.scss formatting
yashjawale Sep 11, 2025
24edb96
refactor: style.scss use base variables
yashjawale Sep 12, 2025
43bb5a3
refactor: optimize comment thread handling in CollabSidebar
yashjawale Sep 12, 2025
22ab72b
Merge branch 'trunk' into feat/comment-toolbar-indicator
yashjawale Sep 12, 2025
b33eb7b
fix: comment 100+ indicator
yashjawale Sep 12, 2025
0f4d335
fix: unused postStatus variable
yashjawale Sep 12, 2025
65ea1fd
fix: irregular hover background on indicator
yashjawale Sep 12, 2025
c11a5c8
refactor: simplify post and comment data retrieval in CollabSidebar u…
yashjawale Sep 12, 2025
71df444
fix: exclude trashed block comments from query
yashjawale Sep 12, 2025
089d6fb
fix: allow multiple comment statuses in REST API requests and simplif…
yashjawale Sep 15, 2025
7d42184
fix: EOL whitespace in block-comments.php
yashjawale Sep 15, 2025
97877fd
Merge branch 'trunk' into feat/comment-toolbar-indicator
yashjawale Sep 15, 2025
7b86a9a
fix: remove function_exists check for gutenberg_filter_rest_comment_c…
yashjawale Sep 15, 2025
e48d5ad
fix: remove memoization from query arguments
yashjawale Sep 15, 2025
d42b3c4
Merge branch 'trunk' into feat/comment-toolbar-indicator
yashjawale Sep 15, 2025
6bff632
Merge branch 'trunk' into feat/comment-toolbar-indicator
yashjawale Sep 15, 2025
781e4d6
Refactor: Remove support for multiple comment statuses in REST API re…
yashjawale Sep 15, 2025
88f1954
Update packages/editor/src/components/collab-sidebar/comment-indicato…
t-hamano Sep 16, 2025
c2080f1
Update packages/editor/src/components/collab-sidebar/comment-indicato…
t-hamano Sep 16, 2025
a8acf34
Update packages/editor/src/components/collab-sidebar/comment-indicato…
t-hamano Sep 16, 2025
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
Prev Previous commit
Next Next commit
refactor: use threadParticipants and enhance avatar styling for origi…
…nal commenters and repliers
  • Loading branch information
yashjawale committed Aug 20, 2025
commit 1f2a1db6af00069a1de2d418c0e2a4ba85b4ade6
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { store as editorStore } from '../../store';
const { CommentIconToolbarSlotFill } = unlock( blockEditorPrivateApis );

const CommentAvatarIndicator = ( { onClick } ) => {
const { commenters, hasUnresolved } = useSelect( ( select ) => {
const { threadParticipants, hasUnresolved } = useSelect( ( select ) => {
const { getBlockAttributes, getSelectedBlockClientId } =
select( blockEditorStore );
const { getCurrentPostId } = select( editorStore );
Expand All @@ -31,7 +31,7 @@ const CommentAvatarIndicator = ( { onClick } ) => {

// Get comment data for this block
const blockCommentIdValue = selectedBlockAttributes?.blockCommentId;
const commentersMap = new Map();
const participantsMap = new Map();
let unresolvedCount = 0;

if ( blockCommentIdValue && postId ) {
Expand All @@ -47,22 +47,35 @@ const CommentAvatarIndicator = ( { onClick } ) => {
);

if ( comments ) {
// Get all comments in this thread (main + replies)
// Get all comments in this thread
// Main comment has id === blockCommentIdValue
// Replies have parent === blockCommentIdValue
const threadComments = comments.filter(
( comment ) =>
comment.id === blockCommentIdValue ||
comment.parent === blockCommentIdValue
);

// Sort by date to show participants in chronological order
threadComments.sort(
( a, b ) => new Date( a.date ) - new Date( b.date )
);

threadComments.forEach( ( comment ) => {
// Track unique commenters
// Track thread participants (original commenter + repliers)
if ( comment.author_name && comment.author_avatar_urls ) {
commentersMap.set( comment.author, {
name: comment.author_name,
avatar:
comment.author_avatar_urls?.[ '48' ] ||
comment.author_avatar_urls?.[ '96' ],
} );
const authorKey = `${ comment.author }-${ comment.author_name }`;
if ( ! participantsMap.has( authorKey ) ) {
participantsMap.set( authorKey, {
name: comment.author_name,
avatar:
comment.author_avatar_urls?.[ '48' ] ||
comment.author_avatar_urls?.[ '96' ],
isOriginalCommenter:
comment.id === blockCommentIdValue,
date: comment.date,
} );
}
}

// Count unresolved comments
Expand All @@ -73,13 +86,16 @@ const CommentAvatarIndicator = ( { onClick } ) => {
}
}

// Convert to array and maintain chronological order
const participants = Array.from( participantsMap.values() );

return {
commenters: Array.from( commentersMap.values() ),
threadParticipants: participants,
hasUnresolved: unresolvedCount > 0,
};
}, [] );

if ( ! commenters.length ) {
if ( ! threadParticipants.length ) {
return null;
}

Expand All @@ -92,8 +108,8 @@ const CommentAvatarIndicator = ( { onClick } ) => {

// Show up to 3 avatars, with overflow indicator
const maxAvatars = 3;
const visibleCommenters = commenters.slice( 0, maxAvatars );
const overflowCount = Math.max( 0, commenters.length - maxAvatars );
const visibleParticipants = threadParticipants.slice( 0, maxAvatars );
const overflowCount = Math.max( 0, threadParticipants.length - maxAvatars );

return (
<CommentIconToolbarSlotFill.Fill>
Expand All @@ -106,19 +122,29 @@ const CommentAvatarIndicator = ( { onClick } ) => {
showTooltip
>
<div className="comment-avatar-stack">
{ visibleCommenters.map( ( commenter, index ) => (
{ visibleParticipants.map( ( participant, index ) => (
<img
key={ commenter.name + index }
src={ commenter.avatar }
alt={ commenter.name }
className="comment-avatar"
key={ participant.name + index }
src={ participant.avatar }
alt={ participant.name }
className={ `comment-avatar ${
participant.isOriginalCommenter
? 'is-original-commenter'
: 'is-replier'
}` }
style={ { zIndex: maxAvatars - index } }
title={
participant.isOriginalCommenter
? `${ participant.name } (started thread)`
: `${ participant.name } (replied)`
}
/>
) ) }
{ overflowCount > 0 && (
<div
className="comment-avatar-overflow"
style={ { zIndex: 0 } }
title={ `+${ overflowCount } more participants` }
>
+{ overflowCount }
</div>
Expand Down
10 changes: 10 additions & 0 deletions packages/editor/src/components/collab-sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@
&:first-child {
margin-left: 0;
}

// Distinguish original commenter with a subtle blue border
&.is-original-commenter {
border-color: #3858e9;
}

// Repliers keep white border
&.is-replier {
border-color: $white;
}
}

.comment-avatar-overflow {
Expand Down
Loading