Skip to content

Commit

Permalink
[PageHeader] Allow multiple breadcrumbs that are not links (#4571)
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Grigorian <[email protected]>
Co-authored-by: Jan Potoms <[email protected]>
  • Loading branch information
null93 and Janpot authored Jan 9, 2025
1 parent ca93987 commit 8ab17a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/pages/toolpad/core/api/page-container.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"props": {
"breadcrumbs": {
"type": { "name": "arrayOf", "description": "Array&lt;{ path: string, title: string }&gt;" }
"type": { "name": "arrayOf", "description": "Array&lt;{ path?: string, title: string }&gt;" }
},
"slotProps": {
"type": {
"name": "shape",
"description": "{ header: { breadcrumbs?: Array&lt;{ path: string, title: string }&gt;, slotProps?: { toolbar: object }, slots?: { toolbar?: elementType }, title?: string } }"
"description": "{ header: { breadcrumbs?: Array&lt;{ path?: string, title: string }&gt;, slotProps?: { toolbar: object }, slots?: { toolbar?: elementType }, title?: string } }"
}
},
"slots": {
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/toolpad/core/api/page-header.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"props": {
"breadcrumbs": {
"type": { "name": "arrayOf", "description": "Array&lt;{ path: string, title: string }&gt;" }
"type": { "name": "arrayOf", "description": "Array&lt;{ path?: string, title: string }&gt;" }
},
"slotProps": { "type": { "name": "shape", "description": "{ toolbar: { children?: node } }" } },
"slots": {
Expand Down
6 changes: 3 additions & 3 deletions packages/toolpad-core/src/PageContainer/PageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Breadcrumb {
/**
* The path the breadcrumb links to.
*/
path: string;
path?: string;
}
export interface PageContainerSlotProps {
header: PageHeaderProps;
Expand Down Expand Up @@ -89,7 +89,7 @@ PageContainer.propTypes /* remove-proptypes */ = {
*/
breadcrumbs: PropTypes.arrayOf(
PropTypes.shape({
path: PropTypes.string.isRequired,
path: PropTypes.string,
title: PropTypes.string.isRequired,
}),
),
Expand All @@ -104,7 +104,7 @@ PageContainer.propTypes /* remove-proptypes */ = {
header: PropTypes.shape({
breadcrumbs: PropTypes.arrayOf(
PropTypes.shape({
path: PropTypes.string.isRequired,
path: PropTypes.string,
title: PropTypes.string.isRequired,
}),
),
Expand Down
8 changes: 4 additions & 4 deletions packages/toolpad-core/src/PageContainer/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ function PageHeader(props: PageHeaderProps) {
<Breadcrumbs aria-label="breadcrumb">
{resolvedBreadcrumbs
? resolvedBreadcrumbs.map((item, index) => {
return index < resolvedBreadcrumbs.length - 1 ? (
return item.path ? (
<Link
key={item.path}
key={index}
component={ToolpadLink}
underline="hover"
color="inherit"
Expand All @@ -94,7 +94,7 @@ function PageHeader(props: PageHeaderProps) {
{getItemTitle(item)}
</Link>
) : (
<Typography key={item.path} color="text.primary">
<Typography key={index} color="text.primary">
{getItemTitle(item)}
</Typography>
);
Expand All @@ -120,7 +120,7 @@ PageHeader.propTypes /* remove-proptypes */ = {
*/
breadcrumbs: PropTypes.arrayOf(
PropTypes.shape({
path: PropTypes.string.isRequired,
path: PropTypes.string,
title: PropTypes.string.isRequired,
}),
),
Expand Down

0 comments on commit 8ab17a3

Please sign in to comment.