From e924fb001cabc1aca8294974b51aa7b831b0bc5f Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 5 Jul 2022 12:53:47 +0200 Subject: [PATCH] Fix app deep linking when mount path set (#2137) --- src/apps/components/AppFrame/useAppActions.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/apps/components/AppFrame/useAppActions.ts b/src/apps/components/AppFrame/useAppActions.ts index 10fa2f60e..49cf04829 100644 --- a/src/apps/components/AppFrame/useAppActions.ts +++ b/src/apps/components/AppFrame/useAppActions.ts @@ -1,9 +1,11 @@ import { Actions, DispatchResponseEvent, Events } from "@saleor/app-bridge"; import { appPath } from "@saleor/apps/urls"; +import { APP_MOUNT_URI } from "@saleor/config"; import useNavigator from "@saleor/hooks/useNavigator"; import React from "react"; import { useIntl } from "react-intl"; import { useLocation } from "react-router"; +import urlJoin from "url-join"; import { useExternalApp } from "../ExternalAppContext"; @@ -52,8 +54,10 @@ export const useAppActions = ( if (newContext) { window.open(to); } else if (appDeepUrlChange) { + const exactLocation = urlJoin(APP_MOUNT_URI, to); + // Change only url without reloading if we are in the same app - window.history.pushState(null, "", to); + window.history.pushState(null, "", exactLocation); } else if (to.startsWith("/")) { navigate(to); closeApp();