Skip to content

Commit

Permalink
Merge pull request #2284 from graphcommerce-org/fix/GCOM-1395
Browse files Browse the repository at this point in the history
fix(GCOM-1395): prevent checkout on looping back and forth with the cart overlay when navigating directly to the checkout
  • Loading branch information
paales authored Jun 26, 2024
2 parents 2feec6e + 60de918 commit 626ec33
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/moody-eggs-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/framer-next-pages': minor
---

Prevent checkout on looping back and forth with the cart overlay when navigating directly to the checkout.
15 changes: 14 additions & 1 deletion packages/framer-next-pages/components/Pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,21 @@ export function FramerNextPages(props: PagesProps) {

let renderItems = [...items.current]

/** Removes the page if the up path equls the path of a overlay and there is no history present **/
const upPath = (renderItems.at(0)?.pageProps?.up as { href: string; title: string })?.href
const overlayPath = renderItems.at(-1)?.routerContext.pageInfo.asPath
if (
renderItems.length === 2 &&
upPath &&
overlayPath &&
upPath === overlayPath &&
renderItems.at(-1)?.overlayGroup
) {
renderItems = renderItems.slice(1)
}

/** We need to render back to the last item that isn't an overlay. */
const plainIdx = findPlainIdx(items.current)
const plainIdx = findPlainIdx(renderItems)

const shouldLoadFb = plainIdx === -1 && typeof window !== 'undefined' && !fb

Expand Down

0 comments on commit 626ec33

Please sign in to comment.