Skip to content

fix(mui): render Breadcrumb links as MUI Link so styling applies - #7503

Closed
adem-loghmari wants to merge 1 commit into
refinedev:mainfrom
adem-loghmari:fix/mui-breadcrumb-link-styling
Closed

adem-loghmari wants to merge 1 commit into
refinedev:mainfrom
adem-loghmari:fix/mui-breadcrumb-link-styling

Conversation

@adem-loghmari

@adem-loghmari adem-loghmari commented Jul 21, 2026 •

Copy link
Copy Markdown

PR Checklist

  • The commit message follows our guidelines
  • Related issue(s) linked
  • Tests for the changes have been added
  • Docs have been added / updated (not needed, no public API change)
  • Changesets have been added

What is the current behavior?

In @refinedev/mui's Breadcrumb, the internal LinkRouter helper is typed to accept MUI LinkProps (sx, underline, color, variant) but renders them onto a bare native <span>:

const LinkRouter = (props: LinkProps & { to?: string }) => {
  const { to, children, ...restProps } = props;
  return (
    <Link to={to || ""}>
      <span {...restProps}>{children}</span>
    </Link>
  );
};

Because <span> is a plain DOM element, none of the MUI styling props do anything, they just get dumped onto the node as invalid HTML attributes. Visible impact: breadcrumb links aren't flex-aligned with their icons, get no hover underline, don't inherit color, and don't get the intended typography size.

This is a regression from the v5 migration (#6945), commit 5d63adac08. Before that, LinkRouter rendered MUI's actual Link. When the legacy-router plumbing was removed in favor of useLink(), the component was rewritten to wrap a <span> but the props were never re-wired to a MUI component. The file still carried an unused import { Link as MuiLink } from "@mui/material" from that incomplete change.

fixes #7462

What is the new behavior?

LinkRouter now renders a real MUI Link, using the router's link component as the underlying element:

<MuiLink component={Link} to={to || ""} {...restProps}>
  {children}
</MuiLink>

This matches the existing pattern used by refine's MUI buttons (component={LinkComponent}), so the styling props (sx, underline, color, variant) are consumed by MUI while client-side routing through to is preserved. The previously-dead MuiLink import is now used.

Notes for reviewers

The shared breadcrumbTests suite (packages/ui-tests) only checks structure (text, href, icon), so this slipped through untested. I added a MUI-specific test in packages/mui/src/components/breadcrumb/index.spec.tsx asserting the rendered link carries the MuiLink-root class and that no styling props leak into the DOM. Verified the test fails on the old <span> implementation and passes with the fix.

@changeset-bot

changeset-bot Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 95c3efb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/mui Patch

Not sure what this means? Click here to learn what changesets are.

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

@stale

stale Bot commented Sep 19, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Sep 19, 2026
The internal LinkRouter helper spread MUI Link props (sx, underline,
color, variant) onto a bare <span>, so none of them took effect:
breadcrumb links lost flex alignment with their icons, hover underline,
inherited color, and typography size.

Render a real MUI Link via component={LinkFromRouter} so the styling
props are consumed by MUI while client-side routing through `to` is
preserved. Also removes the Link as MuiLink import that had been unused
since the v5 migration.

Closes refinedev#7462
@adem-loghmari
adem-loghmari force-pushed the fix/mui-breadcrumb-link-styling branch from 59d42c0 to 95c3efb Compare September 22, 2026 16:55
@adem-loghmari

Copy link
Copy Markdown
Author

Not stale. Rebased onto the latest main (clean, no conflicts) and re-ran the package suite: all 8 tests in packages/mui/src/components/breadcrumb pass, including the styling test added here.

The bug is still reproducible on current main: LinkRouter still spreads the MUI Link props onto a plain <span>, so sx, underline, color and variant are silently dropped on every breadcrumb link. The MuiLink import on line 12 is still unused, which is the clearest sign this was an accident in the v5 migration (5d63ada) rather than intent.

Happy to rebase again or split the test out if that helps review. Closes #7462.

@stale stale Bot closed this Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MUI Breadcrumb links lose all styling — sx/underline/color/variant spread onto a plain <span>

1 participant