Skip to content
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

fix(core): Fix breadcrumb links on PDP #728

Merged
merged 1 commit into from
Apr 3, 2024
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
5 changes: 5 additions & 0 deletions .changeset/sweet-frogs-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Fix breadcrumbs on PDP to have correct links
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const BreadCrumbs = async ({ productId }: Props) => {
return (
<nav>
<ul className="m-0 flex flex-wrap items-center p-0 md:container md:mx-auto ">
{category.breadcrumbs.map((breadcrumb, i, arr) => {
{category.breadcrumbs.map(({ name, path }, i, arr) => {
const isLast = arr.length - 1 === i;

return (
Expand All @@ -26,9 +26,9 @@ export const BreadCrumbs = async ({ productId }: Props) => {
'font-semibold': !isLast,
'font-extrabold': isLast,
})}
key={breadcrumb.name}
key={name}
>
<Link href="#">{breadcrumb.name}</Link>
<Link href={path ?? '#'}>{name}</Link>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we want to do something more complex here if path is null, I'm not sure how much of an edge case that is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it doesn't need to be a link if there is no path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I experimented with this, will also involve remove the hover:text-primary styling above, and I started to wonder if it's worth the complexity (I'm honestly not sure why a category would not have a path)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm honestly not sure why a category would not have a path

Good question, maybe that is something we need to look into at the API level 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed this is an extreme edge case, don't think we need to account for it any more gracefully than this.

{!isLast && <span className="mx-2">/</span>}
</li>
);
Expand Down
1 change: 1 addition & 0 deletions apps/core/client/queries/get-product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const PRODUCT_FRAGMENT = graphql(
edges {
node {
name
path
}
}
}
Expand Down
Loading