Skip to content

feat(comments): collapse sub-comments by default with expand preview#5420

Merged
rebelchris merged 6 commits intomainfrom
eng-515-comments-expanded-by-default-with-option-to-minimize
Jan 30, 2026
Merged

feat(comments): collapse sub-comments by default with expand preview#5420
rebelchris merged 6 commits intomainfrom
eng-515-comments-expanded-by-default-with-option-to-minimize

Conversation

@dailydotdevbot
Copy link
Contributor

@dailydotdevbot dailydotdevbot commented Jan 30, 2026

Summary

  • Sub-comments (replies) are now collapsed by default showing a preview with up to 3 overlapping user avatars and a "View X replies" link
  • Clicking the preview expands to show all replies
  • Main/parent comments remain fully visible - only nested replies collapse

Closes ENG-515

Created by Huginn 🐦‍⬛

Preview domain

https://eng-515-comments-expanded-by-def.preview.app.daily.dev

daily.dev Bot and others added 2 commits January 30, 2026 13:28
Sub-comments (replies) are now collapsed by default and show a preview
with up to 3 overlapping user avatars and a "View X replies" link.
Clicking expands to show all replies. Main comments remain visible.

Resolves ENG-515

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix prettier formatting in spec file (multi-line function params)
- Replace for...of loop with reduce to satisfy no-restricted-syntax rule

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
daily-webapp Ready Ready Preview Jan 30, 2026 2:33pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
storybook Ignored Ignored Jan 30, 2026 2:33pm

Request Review

@CLAassistant
Copy link

CLAassistant commented Jan 30, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ rebelchris
❌ daily.dev Bot


daily.dev Bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rebelchris
Copy link
Contributor

@claude Have another look please, we already added something, it should just be expanded by default, and when minimized show 3 avatars + amount of comments.

@claude
Copy link
Contributor

claude bot commented Jan 30, 2026

Claude finished @rebelchris's task in 5m 27s —— View job


Changes completed

  • Read current implementation
  • Understand the default state logic
  • Invert logic to make expanded the default
  • Use CollapsedRepliesPreview component when collapsed
  • Update tests
  • Run linter
  • Commit and push changes

Summary

I've updated the comment behavior to match your requirements:

What changed:

  1. Expanded by default - Replies now show expanded by default instead of collapsed
  2. CollapsedRepliesPreview component - When users click "Hide replies", they now see the proper preview component with:
    • Up to 3 overlapping user avatars
    • "View X replies" text
  3. Updated tests - All tests now reflect the new behavior

Files modified:

  • MainComment.tsx - Changed default state and integrated CollapsedRepliesPreview component
  • MainComment.spec.tsx - Updated all tests to match new behavior

The linter passed successfully, and changes have been pushed to the branch.

--- |

…mized

- Changed default state to expanded (useState(true))
- Replaced simple button with CollapsedRepliesPreview component showing 3 avatars + count
- Updated tests to reflect new behavior
- Removed unused state variables

Co-authored-by: Chris Bongers <rebelchris@users.noreply.github.com>
Copy link
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude see comments

<button
type="button"
className={classNames(
'flex w-full cursor-pointer items-center gap-2 px-4 py-3 hover:bg-surface-hover',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also be rounded-16 make sure to follow lint rules for order.


const MAX_AVATARS = 3;

export default function CollapsedRepliesPreview({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component should not render if no sub comments.

@claude
Copy link
Contributor

claude bot commented Jan 30, 2026

Claude finished @dailydotdevbot's task in 4m 59s —— View job


Changes completed

  • Read CollapsedRepliesPreview.tsx
  • Fix rounded-16 class order on line 44
  • Add guard clause to prevent rendering with no sub comments
  • Update tests if needed
  • Run linter
  • Commit and push changes

Summary

I've addressed both review comments:

1. Added rounded-16 to button (packages/shared/src/components/comments/CollapsedRepliesPreview.tsx:48)

  • Added rounded-16 class to the button with proper class order following lint rules

2. Guard clause for empty replies (packages/shared/src/components/comments/CollapsedRepliesPreview.tsx:20)

  • Component now returns null when there are no sub comments
  • Moved the early return after hooks to comply with React's rules of hooks
  • Added test case to verify this behavior

Additional fixes:

  • Fixed React hooks rules violation by restructuring the component
  • Updated test to use proper Testing Library methods (queryByRole instead of direct DOM access)
  • All lint checks pass successfully

Changes have been committed and pushed to the branch.

--- | View commit

…with no replies

- Add rounded-16 class to button with proper class order
- Add guard clause to return null when no replies exist
- Fix React hooks rules violation by moving useMemo before early return
- Update test to use proper testing library methods

Co-authored-by: Chris Bongers <rebelchris@users.noreply.github.com>
@rebelchris
Copy link
Contributor

@claude I still see "Hide replies" button when there are no replies.

@claude
Copy link
Contributor

claude bot commented Jan 30, 2026

Claude finished @rebelchris's task in 2m 54s —— View job


Changes completed

  • Read MainComment.tsx to understand current implementation
  • Fix "Hide replies" button to only show when replies exist
  • Update tests if needed
  • Run linter
  • Commit and push changes

Summary

Fixed the issue where the "Hide replies" button was showing even when there were no replies to hide.

What changed:

  • Added replyCount > 0 condition to the "Hide replies" button rendering logic in MainComment.tsx:182
  • Added a test case to verify the button doesn't appear when there are no replies
  • All lint checks pass successfully

The "Hide replies" button will now only show when there are actually replies to hide.


View commit

Co-authored-by: Chris Bongers <rebelchris@users.noreply.github.com>
@rebelchris rebelchris merged commit 26280e0 into main Jan 30, 2026
10 of 11 checks passed
@rebelchris rebelchris deleted the eng-515-comments-expanded-by-default-with-option-to-minimize branch January 30, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants