Skip to content

refactor(portal-plugin-dashboard): add item prop to CollapseMenuButton and update route navigation labels#457

Merged
pcfreak30 merged 1 commit intodevelopfrom
libs/portal-plugin-dashboard
Aug 21, 2025
Merged

refactor(portal-plugin-dashboard): add item prop to CollapseMenuButton and update route navigation labels#457
pcfreak30 merged 1 commit intodevelopfrom
libs/portal-plugin-dashboard

Conversation

@pcfreak30
Copy link
Copy Markdown
Member

@pcfreak30 pcfreak30 commented Aug 21, 2025

  • Added item prop to CollapseMenuButton component to access full navigation item data
  • Updated link generation to prefer item.path over submenu href
  • Added navigation labels for account security and API keys routes

Summary by CodeRabbit

  • New Features

    • Account navigation now includes labeled entries for “Security” and “API Keys.”
    • Collapsible menu headers now support direct navigation using the primary item path.
  • Bug Fixes

    • Header links in collapsible menus now reliably point to the correct destination with a safe fallback and improved keyboard/ARIA behavior for better accessibility.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Aug 21, 2025

⚠️ No Changeset found

Latest commit: c335f08

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 21, 2025

Warning

Rate limit exceeded

@pcfreak30 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 37 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a66fd78 and c335f08.

📒 Files selected for processing (2)
  • libs/portal-framework-ui/src/components/MainNavigation.tsx (3 hunks)
  • libs/portal-plugin-dashboard/src/routes.ts (1 hunks)

Walkthrough

Adds item-aware header linking and accessibility adjustments to CollapseMenuButton in MainNavigation, changes initial collapse/variant logic, and adds navigation labels for two dashboard account subroutes. No route paths, ids, or components changed.

Changes

Cohort / File(s) Summary of Changes
Main navigation: CollapseMenuButton & MainNavigation
libs/portal-framework-ui/src/components/MainNavigation.tsx
CollapseMenuButton now accepts an item: NavigationItemType prop. Header href is computed as `item.path
Dashboard routes: navigation metadata
libs/portal-plugin-dashboard/src/routes.ts
Added navigation: { label: "Security" } to route account_security and navigation: { label: "API Keys" } to route account_api_keys. No changes to ids, paths, or components.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as MainNavigation / CollapseMenuButton
  participant Router

  User->>UI: Click top-level menu header
  Note right of UI #E6F5FF: Header href computed as item.path or first submenu href
  alt headerHref exists
    UI->>Router: Navigate to headerHref (Link with propagation suppression)
  else no headerHref
    UI-->>User: No link (aria-disabled header)
  end

  rect rgba(230,245,255,0.5)
  note right of UI: isCollapsed initial state uses (active || isSubmenuActive)\nButton variant uses (active || isSubmenuActive)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit peeks at menus bright and neat,
I bind the paths where header and submenus meet.
“Security,” “API Keys” now have names to show,
I hop, I link, I make the routes all flow.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch libs/portal-plugin-dashboard

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
libs/portal-framework-ui/src/components/MainNavigation.tsx (1)

55-57: Avoid nested interactive elements and navigation/trigger event conflicts.

Currently the Link is inside a Button which itself is inside a CollapsibleTrigger. This is invalid HTML (interactive inside interactive) and can cause both navigation and collapse toggle to fire on label clicks due to event bubbling.

Recommend:

  • Compute a headerHref once.
  • Render a Link only when headerHref exists; otherwise render a non-interactive <p>.
  • Stop propagation on the Link to avoid toggling the collapsible when navigating.

Apply this diff:

   const [isCollapsed, setIsCollapsed] =
     React.useState<boolean>(isSubmenuActive);
+  const headerHref = item.path || submenus[0]?.href;

@@
-              <Link to={item.path || submenus[0]?.href || "#"}>
-                {/* Link only wraps the text */}
-                <p
-                  className={cn({
-                    "-translate-x-96 opacity-0": !isOpen,
-                    "translate-x-0 opacity-100": isOpen,
-                  })}>
-                  {label}
-                </p>
-              </Link>
+              {headerHref ? (
+                <Link
+                  to={headerHref}
+                  onClick={(e) => e.stopPropagation()}
+                  onKeyDown={(e) => {
+                    if (e.key === " " || e.key === "Enter") e.stopPropagation();
+                  }}
+                  aria-label={label}
+                >
+                  <p
+                    className={cn({
+                      "-translate-x-96 opacity-0": !isOpen,
+                      "translate-x-0 opacity-100": isOpen,
+                    })}
+                  >
+                    {label}
+                  </p>
+                </Link>
+              ) : (
+                <p
+                  className={cn({
+                    "-translate-x-96 opacity-0": !isOpen,
+                    "translate-x-0 opacity-100": isOpen,
+                  })}
+                  aria-disabled="true"
+                >
+                  {label}
+                </p>
+              )}

Notes:

  • This removes the "#" fallback to avoid navigating to an inert hash.
  • For a fuller a11y fix, consider separating the trigger (chevron) from the label link so they are two distinct controls. I can sketch that if you want.

Also applies to: 76-86

🧹 Nitpick comments (3)
libs/portal-framework-ui/src/components/MainNavigation.tsx (1)

66-69: Use parent “active” to style header and initial open state.

When the parent route itself is active (e.g., “/account” with no child active), the header stays in ghost variant and collapsed. Incorporate active so the header reflects the current route.

-  const [isCollapsed, setIsCollapsed] =
-    React.useState<boolean>(isSubmenuActive);
+  const [isCollapsed, setIsCollapsed] =
+    React.useState<boolean>(active || isSubmenuActive);
@@
-          variant={isSubmenuActive ? "secondary" : "ghost"}>
+          variant={active || isSubmenuActive ? "secondary" : "ghost"}>

Also applies to: 55-56

libs/portal-plugin-dashboard/src/routes.ts (2)

27-29: Good: Added navigation label for Account > Security.

This enables a proper menu entry. If your menu supports ordering, consider adding order to control position explicitly.


35-37: Good: Added navigation label for Account > API Keys.

Minor consistency check: confirm title casing (“API Keys”) matches the rest of your nav labels (Title Case vs. Sentence case). Add order if deterministic positioning is needed alongside “Profile” and “Security”.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 190e157 and f085744.

📒 Files selected for processing (2)
  • libs/portal-framework-ui/src/components/MainNavigation.tsx (4 hunks)
  • libs/portal-plugin-dashboard/src/routes.ts (1 hunks)
🔇 Additional comments (2)
libs/portal-framework-ui/src/components/MainNavigation.tsx (2)

33-34: Prop addition looks correct and improves composability.

Adding item: NavigationItemType to CollapseMenuButtonProps and threading it through props gives the header link access to the full nav item. No type issues spotted.

Also applies to: 48-49


203-204: Plumbing item through MainNavigation is consistent.

Passing the full item into CollapseMenuButton is aligned with the new prop and enables the improved link resolution.

@pcfreak30 pcfreak30 force-pushed the libs/portal-plugin-dashboard branch 2 times, most recently from 990dc62 to a66fd78 Compare August 21, 2025 05:52
Copy link
Copy Markdown

@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: 2

🧹 Nitpick comments (2)
libs/portal-framework-ui/src/components/MainNavigation.tsx (2)

33-34: Adding item prop to CollapseMenuButton: LGTM

Passing the full NavigationItemType enables header link derivation and future-proofing for richer behaviors.

If you notice unnecessary re-renders due to item identity changes, consider memoizing CollapseMenuButton or passing only the fields it needs (id, path, label, icon).

Also applies to: 48-49


100-105: Remove aria-disabled from non-interactive text

aria-disabled on a

has no effect and can confuse assistive tech. If the label isn’t a link, just render text; no ARIA is needed. If you want to communicate non-clickable state, rely on visual styling.

Apply this diff:

-                  aria-disabled="true"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f085744 and a66fd78.

📒 Files selected for processing (2)
  • libs/portal-framework-ui/src/components/MainNavigation.tsx (4 hunks)
  • libs/portal-plugin-dashboard/src/routes.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/portal-plugin-dashboard/src/routes.ts
🔇 Additional comments (2)
libs/portal-framework-ui/src/components/MainNavigation.tsx (2)

69-69: Button variant highlights parent when any child is active: good change

Using active || isSubmenuActive for the variant makes the parent visibly active when a submenu is active. This improves UX.


223-224: Passing item through to CollapseMenuButton: LGTM

This wires the new prop correctly and enables the item.path-first header link derivation.

…n and update route navigation labels

- Added `item` prop to CollapseMenuButton component to access full navigation item data
- Updated link generation to prefer item.path over submenu href
- Added navigation labels for account security and API keys routes
- Prevent nested interactive elements in MainNavigation
- Reflect parent route active state in navigation
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.

1 participant