Skip to content

Conversation

@adithya-naik
Copy link
Contributor


📝 Pull Request Description

Description:

This PR fixes the misalignment of the "Show more / Show less" button in the Top Contributors section on the Projects page.
The button was previously off alignment compared to other elements in the card, as described in issue #1329.


Changes Made:

  • Refactored the button into a reusable React component.
  • Ensured proper alignment using Tailwind CSS utility classes.
  • Verified the fix visually in the running development environment.

Related Issue:

Closes #1329


✅ Checklist:

  • UI issue reproduced and confirmed
  • Fix applied and tested locally
  • PR linked to the issue
  • Code follows the repo's style guidelines
  • Contributing guidelines followed

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a new "Show More"/"Show Less" button for expanding and collapsing lists, providing a clearer and more consistent toggle experience.
  • Refactor
    • Updated list components to use the new toggle button, improving UI consistency and encapsulating toggle logic.

Walkthrough

A new ShowMoreButton component was introduced to encapsulate the toggle button logic previously implemented inline in both ToggleableList.tsx and TopContributorsList.tsx. These two components were refactored to use the new ShowMoreButton, removing direct usage of FontAwesome icons and the @heroui/button component for toggling.

Changes

Cohort / File(s) Change Summary
Refactor toggle button usage in list components
frontend/src/components/ToggleableList.tsx, frontend/src/components/TopContributorsList.tsx
Replaced inline toggle button logic (including FontAwesome icons and @heroui/button) with the new ShowMoreButton component. Updated imports and removed unused dependencies.
New toggle button component
frontend/src/components/ShowMoreButton.tsx
Added a new reusable ShowMoreButton component that manages internal expanded state, toggles display text and icons, and triggers a callback. Uses FontAwesome icons and @heroui/button.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • arkid15r
  • kasya

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b99ea12 and 136a54a.

📒 Files selected for processing (2)
  • frontend/src/components/ShowMoreButton.tsx (1 hunks)
  • frontend/src/components/ToggleableList.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/ToggleableList.tsx
  • frontend/src/components/ShowMoreButton.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@adithya-naik
Copy link
Contributor Author

Hi @arkid15r 👋 I've submitted a PR for the issue I was assigned. Please take a moment to review it. If everything looks good and works as expected, feel free to merge it. Thank you! 🙂

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/src/components/ToggleableList.tsx (1)

52-52: Consider extracting button styles to improve maintainability.

The button has an extensive inline className with multiple utility classes. For better maintainability and reusability, consider extracting these styles into a CSS class or a styled component constant.

+const toggleButtonStyles = "bg-blue-50 hover:bg-blue-100 dark:bg-blue-900/20 dark:hover:bg-blue-900/30 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 border border-blue-200 dark:border-blue-800 rounded-md px-4 py-2 font-medium transition-colors"

 <Button
   disableAnimation
   onPress={toggleShowAll}
-  className="bg-blue-50 hover:bg-blue-100 dark:bg-blue-900/20 dark:hover:bg-blue-900/30 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 border border-blue-200 dark:border-blue-800 rounded-md px-4 py-2 font-medium transition-colors"
+  className={toggleButtonStyles}
 >
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00437c0 and c0fb32d.

📒 Files selected for processing (2)
  • frontend/src/components/ToggleableList.tsx (1 hunks)
  • frontend/src/components/TopContributorsList.tsx (1 hunks)
🔇 Additional comments (6)
frontend/src/components/ToggleableList.tsx (3)

47-64: LGTM: Effective alignment fix with comprehensive styling.

The flexbox container with justify-start properly aligns the button to the left, addressing the original issue. The enhanced button styling with background colors, borders, and dark mode support creates a consistent and polished UI component.


47-64: Excellent alignment fix with comprehensive styling!

The button alignment issue has been properly addressed by wrapping it in a flex container with justify-start. The enhanced Tailwind CSS classes provide consistent styling with proper dark mode support, background colors, borders, and smooth transitions.


56-56: Good improvement to icon spacing.

The icon margin adjustment from ml-1 to ml-2 text-sm improves visual balance and consistency. The text-sm class ensures the icon size is appropriate for the button context.

Also applies to: 60-60

frontend/src/components/TopContributorsList.tsx (3)

70-86: LGTM: Consistent alignment fix implementation.

The changes mirror those in ToggleableList.tsx, providing consistent button alignment and styling across both components. The flexbox container effectively addresses the alignment issue mentioned in the PR objectives.


70-86: Perfect alignment fix for the Top Contributors section!

This directly addresses the issue mentioned in #1329. The button is now properly aligned within the card using the flex container with justify-start. The styling is consistent with the ToggleableList component, ensuring a unified UI experience across the application.


74-74: Comprehensive button styling with excellent accessibility.

The detailed Tailwind classes provide:

  • Proper contrast ratios for both light and dark modes
  • Smooth color transitions for better UX
  • Clear visual hierarchy with background, border, and text colors
  • Consistent padding and border radius

This styling approach enhances both usability and visual appeal.

@adithya-naik adithya-naik mentioned this pull request Jul 28, 2025
2 tasks
@adithya-naik
Copy link
Contributor Author

I will submit u the PR with the requested changes shortly @arkid15r

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/src/components/ToggleButton.tsx (1)

17-28: LGTM! Clean conditional rendering implementation.

The conditional rendering logic is well-structured and the icon/text combinations are semantically correct. The wrapper div provides consistent alignment.

Consider wrapping with React.memo if this component re-renders frequently:

+import React from 'react';
+
 // ... other imports

-const ToggleButton = ({ 
+const ToggleButton = React.memo(({ 
   // ... props
-}) => (
+}) => (
   // ... JSX
-);
+));
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0fb32d and 99d028c.

📒 Files selected for processing (3)
  • frontend/src/components/ToggleButton.tsx (1 hunks)
  • frontend/src/components/ToggleableList.tsx (2 hunks)
  • frontend/src/components/TopContributorsList.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/ToggleableList.tsx
  • frontend/src/components/TopContributorsList.tsx
🧰 Additional context used
🧠 Learnings (1)
frontend/src/components/ToggleButton.tsx (1)

Learnt from: Rajgupta36
PR: #1717
File: frontend/tests/unit/pages/ProgramDetails.test.tsx:35-0
Timestamp: 2025-07-12T17:12:25.807Z
Learning: In React applications, button elements should always have an explicit type attribute (type="button", type="submit", or type="reset") to prevent unintended form submission behavior, even when the button appears to be outside of a form context. The default type is "submit" which can cause unexpected behavior.

🔇 Additional comments (3)
frontend/src/components/ToggleButton.tsx (3)

1-3: LGTM!

The imports are well-organized and all are being used in the component.


5-10: Add TypeScript interface for props.

The component is missing TypeScript type definitions, which reduces type safety and IDE support.

Apply this diff to add proper TypeScript typing:

+interface ToggleButtonProps {
+  isExpanded: boolean;
+  onToggle: () => void;
+  showMoreText?: string;
+  showLessText?: string;
+}
+
-const ToggleButton = ({ 
+const ToggleButton = ({ 
   isExpanded, 
   onToggle, 
   showMoreText = "Show more", 
   showLessText = "Show less" 
-}) => (
+}: ToggleButtonProps) => (
⛔ Skipped due to learnings
Learnt from: kasya
PR: OWASP/Nest#1680
File: frontend/src/components/SponsorCard.tsx:3-3
Timestamp: 2025-06-30T00:55:03.133Z
Learning: In the OWASP/Nest project, interfaces or types are not created for component props that are used only once. Inline prop type definitions are preferred for single-use cases.
Learnt from: ahmedxgouda
PR: OWASP/Nest#1714
File: frontend/src/components/ProjectTypeDashboardCard.tsx:8-12
Timestamp: 2025-07-08T17:07:50.988Z
Learning: In the OWASP/Nest project, union types for component props are not necessary when they would require creating separate type definitions. The project prefers inline prop type definitions even for props with specific string values, maintaining consistency with the single-use component prop pattern.
Learnt from: Rajgupta36
PR: OWASP/Nest#1717
File: frontend/__tests__/unit/pages/ProgramDetails.test.tsx:35-0
Timestamp: 2025-07-12T17:12:25.807Z
Learning: In React applications, button elements should always have an explicit type attribute (type="button", type="submit", or type="reset") to prevent unintended form submission behavior, even when the button appears to be outside of a form context. The default type is "submit" which can cause unexpected behavior.

12-26: Confirm HeroUI Button’s default type or add explicit type="button"

I wasn’t able to locate the @heroui/button source in node_modules/ to verify its default type handling. To prevent unintended form submissions, please:

  • Verify in your project’s @heroui/button package (or its docs) whether <Button> defaults to type="button".

  • If it does not set type="button", update your ToggleButton.tsx usage accordingly:

     <Button
  • type="button"
    disableAnimation
    onPress={onToggle}
    className="…"

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@adithya-naik
Copy link
Contributor Author

adithya-naik commented Jul 28, 2025

hey can u review this @arkid15r /@kasya

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

Could you add tests for the new component? I bumped this to 10 points.

@adithya-naik
Copy link
Contributor Author

adithya-naik commented Jul 28, 2025

Could you add tests for the new component? I bumped this to 10 points.

Thanks for the update! @arkid15r 🙌
I'm still a beginner and currently not familiar with writing tests using tools like React Testing Library or Jest. I’ve tried exploring it, but I’m not yet confident enough to implement proper tests for this component.

If it’s okay and you or someone else is able to take care of the tests for now, that would be really helpful. I’ll definitely try to learn this soon and contribute better next time 🙇‍♂️

Thank you for your understanding!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/src/components/ShowMoreButton.tsx (1)

23-32: Conditional rendering logic is correct and accessible.

The component properly toggles between expanded and collapsed states with appropriate icons and text. However, consider adding an aria-expanded attribute for better accessibility.

     <Button
       type="button"
       disableAnimation
       onPress={onToggle}
+      aria-expanded={isExpanded}
       className="flex items-center bg-transparent text-blue-400"
     >
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6923042 and cee026d.

📒 Files selected for processing (3)
  • frontend/src/components/ShowMoreButton.tsx (1 hunks)
  • frontend/src/components/ToggleableList.tsx (2 hunks)
  • frontend/src/components/TopContributorsList.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/src/components/TopContributorsList.tsx
  • frontend/src/components/ToggleableList.tsx
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: adithya-naik
PR: OWASP/Nest#1894
File: frontend/src/components/TopContributorsList.tsx:74-74
Timestamp: 2025-07-28T14:51:14.736Z
Learning: In the OWASP/Nest project, the maintainer adithya-naik prefers not to create separate components for code that's only used in two specific cases, following the YAGNI principle to avoid over-engineering when the duplication is limited and manageable.
🔇 Additional comments (4)
frontend/src/components/ShowMoreButton.tsx (4)

5-15: Props interface looks good with sensible defaults.

The component props are well-defined with appropriate types and default values for the text labels. The optional props pattern allows for customization while providing sensible defaults.


17-22: Button styling addresses the alignment requirements.

The button uses consistent styling with transparent background and blue text color. The flex items-center ensures proper icon alignment within the button.


5-36: Consider the trade-off between reusability and YAGNI principle.

Based on the retrieved learning, the maintainer previously preferred not creating separate components for limited use cases. However, since this component addresses a specific UI alignment issue and is used in exactly two places, the extraction seems justified for:

  1. Consistency: Ensures identical styling and behavior across both usage locations
  2. Maintainability: Centralizes the fix for the alignment issue
  3. Bug Prevention: Reduces the risk of inconsistent implementations

The component strikes a good balance between reusability and simplicity.


16-16: Alignment fix verified for ShowMoreButton

The mt-4 flex justify-start wrapper in frontend/src/components/ShowMoreButton.tsx correctly enforces left alignment in both usages:

  • frontend/src/components/TopContributorsList.tsx
  • frontend/src/components/ToggleableList.tsx

No further changes are required.

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

@kasya any suggestions regarding the UI? Should we keep the previous look?

@adithya-naik adithya-naik requested a review from arkid15r July 29, 2025 12:26
@adithya-naik
Copy link
Contributor Author

Hi @arkid15r,

I've made the following improvements:

  • Removed the isExpanded prop – it's now handled internally.
  • Removed showMoreText and showLessText – using fixed labels instead.
  • Added internal useState for managing the expanded state.
  • Updated the parent components to only pass the onToggle callback.
  • Simplified the interface – now only onToggle is required.

Let me know if this works or if you'd like further changes!

@adithya-naik
Copy link
Contributor Author

Hi @arkid15r,
Is there anything I might be missing or anything else you'd like me to update?
Happy to make any final changes if needed!

@coderabbitai coderabbitai bot mentioned this pull request Jul 29, 2025
2 tasks
@adithya-naik
Copy link
Contributor Author

adithya-naik commented Jul 29, 2025

Hi @arkid15r, I noticed that @coderabbitai referenced this PR in another one (#1908), and I'm not quite sure what's happening here. Could you please help me understand the context or explain what exactly is going on?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 29, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I'll help you understand what's happening! Let me check PR #1908 to see the context of why I referenced this PR.


🏁 Script executed:

#!/bin/bash
# Check what PR #1908 is about and look for references to PR #1894
gh pr view 1908 --json title,body,comments,url

Length of output: 27536


@adithya-naik I can explain what happened!

When I reviewed PR #1908 (which is about making API endpoints available and refactoring backend environment detection logic), I referenced a learning from our conversation in this PR (#1894).

Here's what occurred:

In this PR (#1894), you mentioned your preference not to create separate components for code that's only used in two specific cases, following the YAGNI principle to avoid over-engineering. I stored this as a "learning" in my knowledge base to remember your coding preferences for future reviews.

When I reviewed PR #1908, this learning was relevant to some aspect of the code changes there, so it appeared in the "Learnings" section of my review comment. This is how I maintain context about maintainer preferences across different PRs to provide more personalized and consistent reviews.

This is completely normal behavior - it helps me give better reviews by remembering project-specific preferences and patterns. The reference doesn't mean the PRs are directly related; it just means I applied knowledge from our previous interaction to inform my review of the other PR.

You can see this learning referenced in the "🧠 Learnings" section of my comment on PR #1908, where it shows it was "Learnt from: adithya-naik, PR: #1894".

Hope this clarifies things! Let me know if you have any other questions about how the learning system works.

🐰💭


🧠 Learnings used
Learnt from: adithya-naik
PR: OWASP/Nest#1894
File: frontend/src/components/TopContributorsList.tsx:74-74
Timestamp: 2025-07-28T14:51:14.736Z
Learning: In the OWASP/Nest project, the maintainer adithya-naik prefers not to create separate components for code that's only used in two specific cases, following the YAGNI principle to avoid over-engineering when the duplication is limited and manageable.

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

@adithya-naik Could you also add tests for this newly created component - ShowMoreButton?

@adithya-naik
Copy link
Contributor Author

Could you add tests for the new component? I bumped this to 10 points.

Thanks for the update! @arkid15r 🙌
I'm still a beginner and currently not familiar with writing tests using tools like React Testing Library or Jest. I’ve tried exploring it, but I’m not yet confident enough to implement proper tests for this component.

If it’s okay and you or someone else is able to take care of the tests for now, that would be really helpful. I’ll definitely try to learn this soon and contribute better next time 🙇‍♂️

Thank you for your understanding!

@kasya as i mentioned I don't know how to add test cases as iam a beginner .
Hope you understand! ☺️

@adithya-naik
Copy link
Contributor Author

Hi @arkid15r, @kasya,
Just checking in—any updates on this? Let me know if anything is pending from my side.

@adithya-naik adithya-naik requested a review from kasya July 30, 2025 13:49
@adithya-naik
Copy link
Contributor Author

Also, could you please add the gssoc25 label along with the existing one? That’ll help track contributions better. Thanks!

@adithya-naik adithya-naik requested a review from kasya July 31, 2025 04:52
@sonarqubecloud
Copy link

@kasya
Copy link
Collaborator

kasya commented Jul 31, 2025

Also, could you please add the gssoc25 label along with the existing one? That’ll help track contributions better. Thanks!

The issue has the label - the PR doesn't need to have it.
I also pushed changes - make sure you run make-check and commit changed files. It is required by contributing guidelines for OWASP Nest.

@adithya-naik
Copy link
Contributor Author

Thanks for the clarification, @kasya! 🙌
Since you already pushed some changes, could you also please commit the updated files after running make-check? That would help align it with the contributing guidelines. Appreciate your support!

@kasya kasya enabled auto-merge July 31, 2025 15:20
@kasya kasya dismissed arkid15r’s stale review July 31, 2025 15:22

Already addressed

@kasya kasya added this pull request to the merge queue Jul 31, 2025
Merged via the queue into OWASP:main with commit 80f41ce Jul 31, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show more button misaligned

3 participants