Skip to content

feat(breadcrumbs): Add breadcrumb link max length #93663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions static/app/components/breadcrumbs.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import {Fragment} from 'react';

import {Breadcrumbs} from 'sentry/components/breadcrumbs';
import * as Storybook from 'sentry/stories';

export default Storybook.story('Breadcrumbs', story => {
story('Basics', () => (
<Fragment>
<p>
<Storybook.JSXNode name="Breadcrumbs" /> displays a navigation path with clickable
links. By default, the last item is not clickable to avoid linking to the current
page.
</p>
<Storybook.SizingWindow display="block">
<Breadcrumbs
crumbs={[
{label: 'Organization', to: '/organizations/sentry/'},
{label: 'Projects', to: '/organizations/sentry/projects/'},
{label: 'Project Settings', to: '/settings/projects/javascript/'},
{label: 'General', to: null},
]}
/>
</Storybook.SizingWindow>
</Fragment>
));

story('With Last Item Linked', () => (
<Fragment>
<p>
Set <Storybook.JSXProperty name="linkLastItem" value /> to make the last
breadcrumb clickable.
</p>
<Storybook.SizingWindow display="block">
<Breadcrumbs
linkLastItem
crumbs={[
{label: 'Organization', to: '/organizations/sentry/'},
{label: 'Projects', to: '/organizations/sentry/projects/'},
{label: 'All Projects', to: '/organizations/sentry/projects/all/'},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{label: 'All Projects', to: '/organizations/sentry/projects/all/'},
{label: 'All Projects', to: '/organizations/sentry/projects/'},

i think the 'all' is not needed, it leads to an error

]}
/>
</Storybook.SizingWindow>
</Fragment>
));

story('With Dropdown', () => (
<Fragment>
<p>
Breadcrumbs can include dropdown menus for selecting between multiple options.
</p>
<Storybook.SizingWindow display="block" style={{minHeight: '250px'}}>
<Breadcrumbs
crumbs={[
{label: 'Organization', to: '/organizations/sentry/'},
{
label: 'Select Project',
items: [
{index: 0, value: 'javascript', label: 'JavaScript Project'},
{index: 1, value: 'python', label: 'Python Project'},
{index: 2, value: 'react', label: 'React Project'},
],
onSelect: item => {
// eslint-disable-next-line no-console
console.log('Selected:', item);
},
},
{label: 'Settings', to: null},
]}
/>
</Storybook.SizingWindow>
</Fragment>
));

story('Page Filter Preservation', () => (
<Fragment>
<p>
Use <Storybook.JSXProperty name="preservePageFilters" value /> on individual
crumbs to maintain project/environment/time filters when navigating.
</p>
<Storybook.SizingWindow display="block">
<Breadcrumbs
crumbs={[
{
label: 'Dashboard',
to: '/organizations/sentry/dashboard/',
preservePageFilters: true,
},
{
label: 'Issues',
to: '/organizations/sentry/issues/',
preservePageFilters: true,
},
{label: 'Issue Detail', to: null},
]}
/>
</Storybook.SizingWindow>
</Fragment>
));

story('Different Lengths', () => (
<Fragment>
<p>Examples of breadcrumb trails with different lengths.</p>
<Storybook.SideBySide>
{[
[{label: 'Single Item', to: null}],
[
{label: 'Home', to: '/'},
{label: 'Current Page', to: null},
],
[
{label: 'Organization', to: '/org/'},
{label: 'Project', to: '/project/'},
{label: 'Issues', to: '/issues/'},
{label: 'Issue #123', to: null},
],
[
{
label: 'longlonglonglonglonglonglonglonglonglonglonglonglonglonglong',
to: '/org/',
},
{label: 'Very Long Project Name Here', to: '/project/'},
{label: 'Settings', to: '/settings/'},
{label: 'Performance', to: '/performance/'},
{label: 'Detailed Configuration Page', to: null},
],
].map((crumbs, index) => (
<Fragment key={index}>
<p>
{crumbs.length} item{crumbs.length === 1 ? '' : 's'}
</p>
<Storybook.SizingWindow display="block">
<Breadcrumbs crumbs={crumbs} />
</Storybook.SizingWindow>
</Fragment>
))}
</Storybook.SideBySide>
</Fragment>
));
});
1 change: 1 addition & 0 deletions static/app/components/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const BreadcrumbLink = styled(
)
)`
${getBreadcrumbListItemStyles}
max-width: 400px;

&:hover,
&:active {
Expand Down
Loading