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

sidebar groups, close user menu on outside click #555

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

thomastepi
Copy link
Contributor

  • Close user menu dropdown when click outside the dropdown

  • Re-enabled sidebar groups

@thomastepi thomastepi requested a review from erenfn March 2, 2025 05:14
Copy link
Contributor

coderabbitai bot commented Mar 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces two main changes. In the DropdownMenu component, a new reference (dropdownRef) is added along with a useEffect hook that listens for mouse down events. This change ensures that clicking outside the dropdown automatically closes it. In the LeftMenu component, the previously commented-out menu items are reactivated, adding several new entries and updating icon styling for visual consistency. Both modifications adjust user interactions with the UI without affecting any public exports.

Changes

File Path Change Summary
frontend/src/components/DropdownMenu/…/DropdownMenu.jsx Added dropdownRef using the useRef hook, implemented a useEffect to detect mouse down events outside the dropdown, and wrapped the dropdown button in a div with the reference.
frontend/src/components/LeftMenu/…/LeftMenu.jsx Updated the menuItems array by enabling previously commented-out entries and adding new items (e.g., "SERVE A CONTENT", "Tours", "MAKE AN ANNOUNCEMENT", "GET FEEDBACK") with consistent icon styling.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant DM as DropdownMenu Component
    participant DR as dropdownRef (DOM Element)
    
    U->>DM: Click on page
    DM->>DR: Check if click target is outside dropdown
    alt Click is outside
        DR-->>DM: Return false for containment
        DM->>DM: Set dropdown open state to false (close dropdown)
    else Click is inside
        DR-->>DM: Element contained within dropdown
        DM->>DM: Maintain current state (dropdown remains open)
    end
Loading

📜 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 cc1dc87 and 2165774.

📒 Files selected for processing (1)
  • frontend/src/components/LeftMenu/LeftMenu.jsx (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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/LeftMenu/LeftMenu.jsx (1)

26-26: Missing color styling for the ChecklistIcon

The ChecklistIcon is missing the same styling pattern applied to other icons in the menu items.

-  { text: 'Checklist', icon: <ChecklistIcon /> },
+  { text: 'Checklist', icon: <ChecklistIcon style={{ color: 'var(--menu-icon-color)'}} /> },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 458e104 and cc1dc87.

📒 Files selected for processing (2)
  • frontend/src/components/DropdownMenu/DropdownMenu.jsx (4 hunks)
  • frontend/src/components/LeftMenu/LeftMenu.jsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (22.x)
🔇 Additional comments (6)
frontend/src/components/LeftMenu/LeftMenu.jsx (2)

23-24: Nice work on re-enabling the "SERVE A CONTENT" section and Tours route!

The implementation looks clean and maintains consistent styling with the menu icon color.


27-27: Group title for announcements looks good!

The "MAKE AN ANNOUNCEMENT" title helps organize the sidebar items logically.

frontend/src/components/DropdownMenu/DropdownMenu.jsx (4)

1-1: Good addition of required hooks

The import statement now correctly includes the necessary hooks for the outside click functionality.


12-12: Good implementation of dropdown reference

The useRef hook is properly used to reference the dropdown DOM element.


48-62: Excellent implementation of outside click detection!

This useEffect hook properly handles closing the dropdown when clicking outside, which aligns with the PR objective. The cleanup function correctly removes the event listener to prevent memory leaks.


65-76: Button wrapped properly with ref connection

The dropdown button is now correctly wrapped in a div with the ref attachment, enabling the outside click detection to work as expected.

@erenfn erenfn merged commit 5beb258 into develop Mar 3, 2025
1 of 2 checks passed
@erenfn erenfn deleted the fix/user-menu-dropdown branch March 5, 2025 21:06
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.

2 participants