Skip to content

fix (breadcrumb): ref not forwarded for trigger#694

Open
paanSinghCoder wants to merge 2 commits intomainfrom
fix/breadcrumb-ref-not-forwarded
Open

fix (breadcrumb): ref not forwarded for trigger#694
paanSinghCoder wants to merge 2 commits intomainfrom
fix/breadcrumb-ref-not-forwarded

Conversation

@paanSinghCoder
Copy link
Contributor

@paanSinghCoder paanSinghCoder commented Mar 11, 2026

Description

fix: Forward ref when BreadcrumbItem uses dropdown
fix: Props silently ignored in dropdown path

When BreadcrumbItem is used with dropdownItems, the forwarded ref and other props was never attached and was effectively dropped. The ref and other props are now passed through to Menu.Trigger, so callers can attach a ref to the same interactive element in both link and dropdown variants.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes, no bug fixes just code improvements)
  • Chore (changes to the build process or auxiliary tools and libraries such as documentation generation)
  • Style (changes that do not affect the meaning of the code (white-space, formatting, etc))
  • Test (adding missing tests or correcting existing tests)
  • Improvement (Improvements to existing code)
  • Other (please specify)

How Has This Been Tested?

Manual

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (.mdx files)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Screenshots (if appropriate):

[Add screenshots here]

Related Issues

[Link any related issues here using #issue-number]

Summary by CodeRabbit

Release Notes

  • Refactor
    • Improved internal handling of breadcrumb dropdown triggers to enhance component stability and maintainability. No changes to user-facing functionality or behavior.

@paanSinghCoder paanSinghCoder self-assigned this Mar 11, 2026
@vercel
Copy link

vercel bot commented Mar 11, 2026

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

Project Deployment Actions Updated (UTC)
apsara Ready Ready Preview, Comment Mar 11, 2026 10:34am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

BreadcrumbItem's dropdown trigger now forwards a ref (cast to HTMLButtonElement) and forwards id, title, and ARIA attributes to the Menu.Trigger. Change is internal, public API and dropdown rendering remain unchanged.

Changes

Cohort / File(s) Summary
Breadcrumb Dropdown Ref Forwarding
packages/raystack/components/breadcrumb/breadcrumb-item.tsx
Menu.Trigger now receives a forwarded ref (HTMLButtonElement) and propagates className, id, title, and ARIA attributes (aria-label, aria-labelledby, aria-describedby) from props; dropdown rendering and public API unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

🐰 A little ref hopped to the gate,
Button found its name and state,
ARIA and ids snug in a row,
Breadcrumbs whisper where to go,
I nibble code and watch it grow. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: forwarding a ref to the Menu.Trigger component in BreadcrumbItem when dropdownItems are used.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/breadcrumb-ref-not-forwarded

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/raystack/components/breadcrumb/breadcrumb-item.tsx`:
- Around line 58-61: The component declares the forwarded ref as
HTMLAnchorElement but sometimes forwards it to Menu.Trigger (an
HTMLButtonElement), causing a type mismatch; update the ref type on the
component (the forwarded ref symbol `ref`) to widen it to either
`HTMLAnchorElement | HTMLButtonElement` or `HTMLElement` so callers' refs remain
correct, and adjust the prop/forwardRef signature where `ref` is declared (the
forwardRef in breadcrumb-item.tsx) to use the chosen union/HTMLElement type and
update any local casts so the `Menu.Trigger` usage no longer force-casts `ref`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: adad8e04-c918-4548-baf2-9986ee0f80b1

📥 Commits

Reviewing files that changed from the base of the PR and between 14de0ba and 9c159ad.

📒 Files selected for processing (1)
  • packages/raystack/components/breadcrumb/breadcrumb-item.tsx

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

Caution

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

⚠️ Outside diff range comments (1)
packages/raystack/components/breadcrumb/breadcrumb-item.tsx (1)

55-82: ⚠️ Potential issue | 🔴 Critical

Dropdown path must wrap in <li> element to maintain valid list semantics.

The non-dropdown path wraps content in <li className={...}> but the dropdown path returns <Menu> directly. Since the parent BreadcrumbRoot renders <ol> and expects <li> children, the dropdown path violates semantic HTML. This produces invalid DOM structure (<ol><Menu>...</Menu></ol>) and breaks accessibility expectations for breadcrumb navigation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/raystack/components/breadcrumb/breadcrumb-item.tsx` around lines 55
- 82, The dropdown branch in breadcrumb-item.tsx returns <Menu> directly which
breaks the parent <ol> semantics; wrap the existing Menu JSX inside the same <li
className={cx(styles['breadcrumb-item'], className)}> wrapper used by the
non-dropdown path so the component always renders an <li> child for
BreadcrumbRoot. Keep the same ref usage on Menu.Trigger, preserve id/title/aria
props and the dropdownItems mapping to Menu.Item, and ensure the className uses
styles['breadcrumb-item'] (or the same variable used in the non-dropdown branch)
so styling and semantics remain consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/raystack/components/breadcrumb/breadcrumb-item.tsx`:
- Around line 58-66: The dropdown branch only forwards specific props to
Menu.Trigger (id, title, aria-*) causing data-*, other ARIA attributes, and
event handlers to be dropped when dropdownItems is present; update the
Menu.Trigger call in breadcrumb-item.tsx (the dropdown path where Menu.Trigger
is rendered) to spread the remaining props (e.g., include ...props or a
filteredProps object) so that Menu.Trigger receives the same external attributes
and event handlers as the non-dropdown path (which uses ...props), ensuring
consistent prop forwarding for dropdownItems and non-dropdown variants.

---

Outside diff comments:
In `@packages/raystack/components/breadcrumb/breadcrumb-item.tsx`:
- Around line 55-82: The dropdown branch in breadcrumb-item.tsx returns <Menu>
directly which breaks the parent <ol> semantics; wrap the existing Menu JSX
inside the same <li className={cx(styles['breadcrumb-item'], className)}>
wrapper used by the non-dropdown path so the component always renders an <li>
child for BreadcrumbRoot. Keep the same ref usage on Menu.Trigger, preserve
id/title/aria props and the dropdownItems mapping to Menu.Item, and ensure the
className uses styles['breadcrumb-item'] (or the same variable used in the
non-dropdown branch) so styling and semantics remain consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 08e69747-c14b-4753-b829-bd9a6e0332e2

📥 Commits

Reviewing files that changed from the base of the PR and between 9c159ad and c6e9277.

📒 Files selected for processing (1)
  • packages/raystack/components/breadcrumb/breadcrumb-item.tsx

Comment on lines +58 to +66
<Menu.Trigger
ref={ref as React.Ref<HTMLButtonElement>}
className={cx(styles['breadcrumb-dropdown-trigger'], className)}
id={props.id}
title={props.title}
aria-label={props['aria-label']}
aria-labelledby={props['aria-labelledby']}
aria-describedby={props['aria-describedby']}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistent prop forwarding between dropdown and non-dropdown paths.

The non-dropdown path spreads all props via ...props (line 94), but the dropdown path only forwards a subset (id, title, and three ARIA attributes). This means data-* attributes, other ARIA attributes, and event handlers passed by callers will be silently ignored when dropdownItems is provided.

Consider spreading the remaining props to Menu.Trigger for consistency, or document the limited prop support for the dropdown variant.

Suggested fix to forward remaining props
          <Menu.Trigger
            ref={ref as React.Ref<HTMLButtonElement>}
            className={cx(styles['breadcrumb-dropdown-trigger'], className)}
-            id={props.id}
-            title={props.title}
-            aria-label={props['aria-label']}
-            aria-labelledby={props['aria-labelledby']}
-            aria-describedby={props['aria-describedby']}
+            {...props}
          >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Menu.Trigger
ref={ref as React.Ref<HTMLButtonElement>}
className={cx(styles['breadcrumb-dropdown-trigger'], className)}
id={props.id}
title={props.title}
aria-label={props['aria-label']}
aria-labelledby={props['aria-labelledby']}
aria-describedby={props['aria-describedby']}
>
<Menu.Trigger
ref={ref as React.Ref<HTMLButtonElement>}
className={cx(styles['breadcrumb-dropdown-trigger'], className)}
{...props}
>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/raystack/components/breadcrumb/breadcrumb-item.tsx` around lines 58
- 66, The dropdown branch only forwards specific props to Menu.Trigger (id,
title, aria-*) causing data-*, other ARIA attributes, and event handlers to be
dropped when dropdownItems is present; update the Menu.Trigger call in
breadcrumb-item.tsx (the dropdown path where Menu.Trigger is rendered) to spread
the remaining props (e.g., include ...props or a filteredProps object) so that
Menu.Trigger receives the same external attributes and event handlers as the
non-dropdown path (which uses ...props), ensuring consistent prop forwarding for
dropdownItems and non-dropdown variants.

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