Skip to content

feat(ui): add breadcrumbs UI to PluginHeader - #34587

Merged
clairep94 merged 11 commits into
masterfrom
clairep_addBreadcrumbsToPluginHeader
Jun 22, 2026
Merged

clairep94 merged 11 commits into
masterfrom
clairep_addBreadcrumbsToPluginHeader

Conversation

@clairep94

@clairep94 clairep94 commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator

Hey, I just made a Pull Request!

Screen.Recording.2026-06-14.at.15.48.24.mov
  • Add breadcrumbs to PluginHeader
    • Segments show tooltip if truncated
    • Collapses middle segments into a ellipse menu if more than 5 entries

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@backstage-goalie backstage-goalie Bot added size:large Large pull requests receive a slightly lower priority for reviews. waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner. labels Jun 14, 2026
@github-actions

github-actions Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Visual Testing with Chromatic

@clairep94
clairep94 force-pushed the clairep_addBreadcrumbsToPluginHeader branch from db166d0 to 5614020 Compare June 14, 2026 12:50
@clairep94
clairep94 force-pushed the clairep_addUseBreadcrumbsHook branch from dc4642e to 29f00e1 Compare June 14, 2026 13:00
@backstage-goalie

Copy link
Copy Markdown
Contributor

Thanks for the contribution!
All commits need to be DCO signed before they are reviewed. Please refer to the the DCO section in CONTRIBUTING.md or the DCO status for more info.

@clairep94
clairep94 force-pushed the clairep_addBreadcrumbsToPluginHeader branch 4 times, most recently from fdf944c to 66b21c5 Compare June 14, 2026 14:44
- passed via breadcrumbs prop
- collapses middle segments if more than 5 segments
- shows tooltip if text is truncated

Signed-off-by: Claire Peng <[email protected]>
@clairep94
clairep94 force-pushed the clairep_addBreadcrumbsToPluginHeader branch from 66b21c5 to 772a190 Compare June 14, 2026 14:48
@clairep94
clairep94 marked this pull request as ready for review June 14, 2026 14:51
@clairep94
clairep94 requested a review from a team as a code owner June 14, 2026 14:51
@clairep94 clairep94 changed the title Clairep add breadcrumbs to plugin header feat(ui): add breadcrumbs prop & breadcrumbs to PluginHeader Jun 14, 2026
Comment on lines +72 to +79
useIsomorphicLayoutEffect(() => {
const el = ref.current;
if (!el) return undefined;

const check = () => setTruncated(el.scrollWidth > el.clientWidth);

return observeResize(el, check);
}, []);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we don't reaaaally need this on PluginHeader breadcrumbs because the max-width is fixed, but I had this from the previous PR attempt and it might be useful for other text elements in the future

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure I follow, wouldn't we need this to pick up changes where the window is resized? Or how would we do it without?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For if a sibling component changed size and affected the amount of space that a current component's text has to occupy

Eg. being able to drag the sibling's width

<RACBreadcrumb key="collapsed">
<BreadcrumbTooltipWrapper label={ariaLabel} showTooltip>
<MenuTrigger>
<RACButton aria-label={ariaLabel} className={ellipsisClassName}>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Using this instead of BUI Button to prevent layout shift from the button's padding, when we go from uncollapse to collapsed

@clairep94 clairep94 changed the title feat(ui): add breadcrumbs prop & breadcrumbs to PluginHeader feat(ui): add breadcrumbs UI to PluginHeader Jun 14, 2026

@Naycon Naycon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Found a tooltip bug, and we may need to do something about the last segment overflowing.

Comment on lines +96 to +104
<Menu>
{items.map(item => (
<MenuItem key={item.href} href={item.href}>
{item.label}
</MenuItem>
))}
</Menu>
</MenuTrigger>
</BreadcrumbTooltipWrapper>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In addition to the trigger, we get tooltips on the menu items as well when hovered with the mouse. I wonder if it could be because we're wrapping the menu items in Tooltip as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah shall we just remove this tooltip? it's aria-labeled already and within Portal there's mix useage of icon buttons having tooltips vs. not

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

@backstage-goalie backstage-goalie Bot added waiting-for:author Changes have been requested and the PR will not receive a review until the changes are made. and removed waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner. labels Jun 17, 2026
icon?: React.ReactNode;
title?: string;
titleLink?: string;
breadcrumbs?: BreadcrumbEntry[];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it'd make sense for this component to own it's own Breadcrumb shape, so I believe we should have this type defined here instead. Fine to duplicate and have two types, one for the hook and one here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done!

const ref = useRef<T>(null);
const [truncated, setTruncated] = useState(false);

// Re-check after each render in case the content changes without a resize event.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When would this happen?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

if there were a sibling component that changed size, and that made our text start to truncate

Comment on lines +72 to +79
useIsomorphicLayoutEffect(() => {
const el = ref.current;
if (!el) return undefined;

const check = () => setTruncated(el.scrollWidth > el.clientWidth);

return observeResize(el, check);
}, []);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure I follow, wouldn't we need this to pick up changes where the window is resized? Or how would we do it without?

- remove useBreadcrumbs hook
- remove BreadcrumbEntry type
- remove BreadcrumbsRegistration & BreadcrumbsRegistryProvider

Signed-off-by: Claire Peng <[email protected]>
@clairep94
clairep94 marked this pull request as draft June 22, 2026 09:29
@backstage-goalie backstage-goalie Bot added waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner. and removed waiting-for:author Changes have been requested and the PR will not receive a review until the changes are made. labels Jun 22, 2026
@clairep94
clairep94 changed the base branch from clairep_addUseBreadcrumbsHook to master June 22, 2026 09:29
@backstage-goalie

Copy link
Copy Markdown
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/ui packages/ui patch v0.16.0

@clairep94 clairep94 mentioned this pull request Jun 22, 2026
7 tasks done
@clairep94
clairep94 force-pushed the clairep_addBreadcrumbsToPluginHeader branch from 07ac0fc to 26e411c Compare June 22, 2026 10:08
…focusable with tooltip if truncated

Signed-off-by: Claire Peng <[email protected]>
@clairep94
clairep94 marked this pull request as ready for review June 22, 2026 11:44
Copilot AI review requested due to automatic review settings June 22, 2026 11:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds optional breadcrumbs support to PluginHeader in @backstage/ui, including truncation-aware tooltips and an ellipsis menu that collapses middle segments for longer trails.

Changes:

  • Introduces breadcrumbs?: PluginHeaderBreadcrumbEntry[] on PluginHeader and exports the new public type.
  • Adds PluginHeaderBreadcrumbs component with ellipsis collapse behavior and truncation tooltips (via useIsTruncated).
  • Updates styling, Storybook stories, tests, API report, and includes a changeset.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/ui/src/components/PluginHeader/useIsTruncated.ts New hook to detect truncation (with ResizeObserver + debounce).
packages/ui/src/components/PluginHeader/useIsTruncated.test.tsx Unit tests for truncation detection and debounced resize behavior.
packages/ui/src/components/PluginHeader/types.ts Adds breadcrumbs prop and new public breadcrumb entry type.
packages/ui/src/components/PluginHeader/PluginHeaderBreadcrumbs.tsx New breadcrumbs UI, tooltip-on-truncation, and collapse-to-ellipsis logic.
packages/ui/src/components/PluginHeader/PluginHeaderBreadcrumbs.test.tsx Tests for rendering, collapsing behavior, and tooltip behavior.
packages/ui/src/components/PluginHeader/PluginHeader.tsx Renders breadcrumbs when provided and visually hides the title heading.
packages/ui/src/components/PluginHeader/PluginHeader.test.tsx Tests for PluginHeader rendering, including breadcrumbs cases.
packages/ui/src/components/PluginHeader/PluginHeader.stories.tsx Adds Storybook stories demonstrating breadcrumbs configurations.
packages/ui/src/components/PluginHeader/PluginHeader.module.css Adds breadcrumbs styling + layout adjustments to support truncation/collapsing.
packages/ui/src/components/PluginHeader/index.tsx Re-exports PluginHeaderBreadcrumbEntry.
packages/ui/src/components/PluginHeader/definition.ts Adds classNames/propDefs entries for breadcrumbs styling hooks.
packages/ui/report.api.md Updates API report for the new exported type and prop.
.changeset/great-states-smash.md Changeset describing the new breadcrumbs prop behavior.

Comment on lines +85 to +94
const { ref, truncated } = useIsTruncated<HTMLParagraphElement>();

return (
<BreadcrumbTooltipWrapper label={entry.label} showTooltip={truncated}>
<Focusable excludeFromTabOrder={!truncated}>
<Text
variant="body-medium"
truncate
ref={ref as React.Ref<HTMLParagraphElement>}
>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This causes a type-error when we do this, it's set in Text. I'm hesitant to change this as I don't know the context for why Text's ref type is HTMLParagraphElement instead of an enum that includes HTMLSpanElement

}

return (
<nav id="Breadcrumbs" className={className}>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Currently BUI design will not have multiple breadcrumbs throughout the app

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe it's still useful to set a aria-label for the navigation landmark? I assume the id won't become the label automatically, or is that sufficient?

Comment thread .changeset/great-states-smash.md Resolved
Signed-off-by: Claire Peng <[email protected]>

@Naycon Naycon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good! Some minor things to take a second look at, but I'll pre-approve because it's also shippable as-is. Thanks for adding this in Claire!

These breadcrumbs:

- Collapses middle segments if 5 or more segments
- Shows tooltip if text is truncated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should have an affected components string here, like so:

Suggested change
- Shows tooltip if text is truncated
- Shows tooltip if text is truncated
**Affected components:** PluginHeader

These breadcrumbs:

- Collapses middle segments if 5 or more segments
- Shows tooltip if text is truncated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should have an affected components string here, like so:

Suggested change
- Shows tooltip if text is truncated
- Shows tooltip if text is truncated
**Affected components:** PluginHeader

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated

standalone
variant="body-medium"
truncate
ref={ref as React.Ref<HTMLAnchorElement>}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could this cast be avoided by explicitly typing the return value of useIsTrucnated?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated

}

return (
<nav id="Breadcrumbs" className={className}>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe it's still useful to set a aria-label for the navigation landmark? I assume the id won't become the label automatically, or is that sufficient?

@backstage-goalie backstage-goalie Bot added waiting-for:merge The PR has been approved and is awaiting merge. and removed waiting-for:review The PR needs a review and will be visible in the review queue unless already assigned an owner. labels Jun 22, 2026
Signed-off-by: Claire Peng <[email protected]>
Copilot AI review requested due to automatic review settings June 22, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment on lines +85 to +92
const { ref, truncated } = useIsTruncated<HTMLParagraphElement>();

return (
<BreadcrumbTooltipWrapper label={entry.label} showTooltip={truncated}>
<Focusable excludeFromTabOrder={!truncated}>
<Text variant="body-medium" truncate ref={ref}>
{entry.label}
</Text>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

see comment here:
#34587 (comment)

}

return (
<nav id="Breadcrumbs" aria-label="Breadcrumbs" className={className}>
@clairep94
clairep94 enabled auto-merge June 22, 2026 14:43
@clairep94
clairep94 merged commit 0e6e446 into master Jun 22, 2026
25 checks passed
@clairep94
clairep94 deleted the clairep_addBreadcrumbsToPluginHeader branch June 22, 2026 15:03
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.53.0 release, scheduled for Tue, 14 Jul 2026.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:large Large pull requests receive a slightly lower priority for reviews. waiting-for:merge The PR has been approved and is awaiting merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants