Skip to content

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

Merged
rohanchkrabrty merged 6 commits intomainfrom
fix/breadcrumb-ref-not-forwarded
Mar 21, 2026
Merged

fix (Breadcrumb): ref not forwarded for trigger#694
rohanchkrabrty merged 6 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

  • Refactor

    • Improved internal component prop handling for better code organization.
  • Style

    • Fixed code formatting in stylesheets.

@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 20, 2026 10:07am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3ff7f6d-15fb-4e36-99e9-8490035099c6

📥 Commits

Reviewing files that changed from the base of the PR and between c672ac4 and 3434653.

📒 Files selected for processing (3)
  • apps/www/src/content/docs/components/navbar/demo.css
  • packages/raystack/components/breadcrumb/breadcrumb-item.tsx
  • packages/raystack/components/navbar/navbar.module.css
✅ Files skipped from review due to trivial changes (2)
  • apps/www/src/content/docs/components/navbar/demo.css
  • packages/raystack/components/navbar/navbar.module.css
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/raystack/components/breadcrumb/breadcrumb-item.tsx

📝 Walkthrough

Walkthrough

The BreadcrumbItem component is refactored to explicitly destructure and assign id, title, and aria-* attributes to Menu.Trigger instead of spreading the full button cast. The non-dropdown branch ensures ref is included in cloned element props. Two CSS files receive trailing newline formatting adjustments.

Changes

Cohort / File(s) Summary
Breadcrumb Props & Ref Handling
packages/raystack/components/breadcrumb/breadcrumb-item.tsx
Destructures id, title, and aria-* attributes from props; applies them explicitly to Menu.Trigger. In non-dropdown branch, ensures ref is included in cloned element props while maintaining consistent spread order.
CSS Formatting
apps/www/src/content/docs/components/navbar/demo.css, packages/raystack/components/navbar/navbar.module.css
Added trailing newlines to resolve "no newline at end of file" markers in both CSS files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • rsbh
  • rohanchkrabrty

Poem

🐰 A breadcrumb trail now shines so bright,
With refs and props aligned just right,
Aria-labels find their place,
CSS newlines grace each space! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main bug fix: ref forwarding in the Breadcrumb component's dropdown trigger, which is the primary focus of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/breadcrumb-ref-not-forwarded
📝 Coding Plan
  • Generate coding plan for human review comments

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

@paanSinghCoder paanSinghCoder changed the title fix (breadcrumb): ref not forwarded for trigger fix (Breadcrumb): ref not forwarded for trigger Mar 12, 2026
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 public ref type for BreadcrumbItem is incorrect because
BreadcrumbItem is declared as forwardRef<HTMLAnchorElement, ...> but when
dropdownItems is present you pass that ref into Menu.Trigger (an
HTMLButtonElement) via ref; change the component's ref type to accurately
reflect both render paths—replace forwardRef<HTMLAnchorElement, ...> with a
widened ref type such as forwardRef<HTMLAnchorElement | HTMLButtonElement,
Props> or use a generic HTMLElement/Element ref (React.Ref<HTMLAnchorElement |
HTMLButtonElement> or React.Ref<HTMLElement>) so callers get the correct element
type, and update any related prop/ref typings and exports (e.g., BreadcrumbItem,
Menu.Trigger usage, and the props interface) to avoid casting the ref with "as".

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3d86560a-642e-4661-9486-862b1bbc2279

📥 Commits

Reviewing files that changed from the base of the PR and between c6e9277 and 7df155f.

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

Comment on lines +58 to +61
<Menu.Trigger
ref={ref as React.Ref<HTMLButtonElement>}
className={cx(styles['breadcrumb-dropdown-trigger'], className)}
{...(props as React.ButtonHTMLAttributes<HTMLButtonElement>)}
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "BreadcrumbItem signature and dropdown ref cast:"
sed -n '20,65p' packages/raystack/components/breadcrumb/breadcrumb-item.tsx

echo
echo "Menu.Trigger definition and forwarded ref target:"
rg -n -C3 'forwardRef<|Trigger' packages/raystack/components/menu

Repository: raystack/apsara

Length of output: 16283


Don't cast the public anchor ref to a button ref.

Line 59 keeps BreadcrumbItem publicly typed as forwardRef<HTMLAnchorElement>, but the dropdown path now writes that ref into Menu.Trigger as HTMLButtonElement. A caller with useRef<HTMLAnchorElement>() will receive a button when dropdownItems is set, so the exported type is now lying. Widen or split the ref type so it matches the rendered element instead of hiding the mismatch with a cast.

🤖 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
- 61, The public ref type for BreadcrumbItem is incorrect because BreadcrumbItem
is declared as forwardRef<HTMLAnchorElement, ...> but when dropdownItems is
present you pass that ref into Menu.Trigger (an HTMLButtonElement) via ref;
change the component's ref type to accurately reflect both render paths—replace
forwardRef<HTMLAnchorElement, ...> with a widened ref type such as
forwardRef<HTMLAnchorElement | HTMLButtonElement, Props> or use a generic
HTMLElement/Element ref (React.Ref<HTMLAnchorElement | HTMLButtonElement> or
React.Ref<HTMLElement>) so callers get the correct element type, and update any
related prop/ref typings and exports (e.g., BreadcrumbItem, Menu.Trigger usage,
and the props interface) to avoid casting the ref with "as".

<Menu.Trigger
ref={ref as React.Ref<HTMLButtonElement>}
className={cx(styles['breadcrumb-dropdown-trigger'], className)}
{...(props as React.ButtonHTMLAttributes<HTMLButtonElement>)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not pass AnchorElement props to MenuTrigger

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Passing only apt props.

@rohanchkrabrty rohanchkrabrty merged commit 01975d6 into main Mar 21, 2026
5 checks passed
@rohanchkrabrty rohanchkrabrty deleted the fix/breadcrumb-ref-not-forwarded branch March 21, 2026 07:26
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.

[Breadcrumb] Structural improvements and feature enhancements

2 participants