From 037d35162cfad22bdba036971275d1dc656e7ee7 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 20 Apr 2023 17:36:38 +0400 Subject: [PATCH] Fix a bug when link to Home doesn't work on a published site (#1503) ## Description Context: https://discord.com/channels/955905230107738152/1098457250235957258 Fix of the bug: on a published site, when you point a link to Page=Home, the rendered `href` contains path of the current page. This is most likely due to `homePage.path === ""` and when we pass `to=""` to RemixLink it behaves like this. So I made sure we pass `to="/"` for the home page. --- .../react-sdk/src/app/custom-components/shared/remix-link.tsx | 2 +- packages/react-sdk/src/components/link.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-sdk/src/app/custom-components/shared/remix-link.tsx b/packages/react-sdk/src/app/custom-components/shared/remix-link.tsx index 427c0f8d49..e5aef71851 100644 --- a/packages/react-sdk/src/app/custom-components/shared/remix-link.tsx +++ b/packages/react-sdk/src/app/custom-components/shared/remix-link.tsx @@ -12,7 +12,7 @@ export const wrapLinkComponent = (BaseLink: LinkComponent) => { const href = usePropUrl(getInstanceIdFromComponentProps(props), "href"); if (href?.type === "page") { - let to = href.page.path; + let to = href.page.path === "" ? "/" : href.page.path; if (href.hash !== undefined) { to += `#${href.hash}`; } diff --git a/packages/react-sdk/src/components/link.tsx b/packages/react-sdk/src/components/link.tsx index 2418af3138..50fed5192f 100644 --- a/packages/react-sdk/src/components/link.tsx +++ b/packages/react-sdk/src/components/link.tsx @@ -23,7 +23,7 @@ export const Link = forwardRef((props, ref) => { switch (href?.type) { case "page": - url = href.page.path; + url = href.page.path === "" ? "/" : href.page.path; if (href.hash !== undefined) { url += `#${href.hash}`; }