diff --git a/src/app/AppRegistry.tsx b/src/app/AppRegistry.tsx index 7b74c1d021a..3892957f6ba 100644 --- a/src/app/AppRegistry.tsx +++ b/src/app/AppRegistry.tsx @@ -730,6 +730,7 @@ export const modules = defineModules({ Component: HomeViewScreen, options: { isRootViewForTabName: "home", + onlyShowInTabName: "home", fullBleed: true, screenOptions: { headerShown: false, @@ -758,6 +759,7 @@ export const modules = defineModules({ Component: InboxQueryRenderer, options: { isRootViewForTabName: "inbox", + onlyShowInTabName: "inbox", fullBleed: true, screenOptions: { headerShown: false, @@ -926,6 +928,7 @@ export const modules = defineModules({ Component: MyProfile, options: { isRootViewForTabName: "profile", + onlyShowInTabName: "profile", fullBleed: true, screenOptions: { headerShown: false, @@ -1124,6 +1127,7 @@ export const modules = defineModules({ Component: SellWithArtsy, options: { isRootViewForTabName: "sell", + onlyShowInTabName: "sell", fullBleed: true, screenOptions: { headerShown: false, @@ -1154,6 +1158,7 @@ export const modules = defineModules({ Component: SearchScreen, options: { isRootViewForTabName: "search", + onlyShowInTabName: "search", fullBleed: true, screenOptions: { headerShown: false, diff --git a/src/app/Components/ArtsyWebView.tsx b/src/app/Components/ArtsyWebView.tsx index ecc1e15325a..c7a1d41906c 100644 --- a/src/app/Components/ArtsyWebView.tsx +++ b/src/app/Components/ArtsyWebView.tsx @@ -258,7 +258,6 @@ export const ArtsyWebView = forwardRef< if (shouldDismissModal) { dismissModal(() => { - // We need to navigate only after the modal has been dismissed to avoid a race // condition breaking the UI navigate(targetURL) }) diff --git a/src/app/routes.ts b/src/app/routes.ts index ff99dffdc3c..43784b26430 100644 --- a/src/app/routes.ts +++ b/src/app/routes.ts @@ -71,6 +71,7 @@ export function addWebViewRoute(url: string, config?: ArtsyWebViewConfig) { config?.alwaysPresentModally ? "ModalWebView" : "ReactWebView", (params) => ({ url: replaceParams(url, params), + isPresentedModally: !!config?.alwaysPresentModally, ...config, }) ) diff --git a/src/app/system/navigation/navigate.ts b/src/app/system/navigation/navigate.ts index 6a7181c80c2..afa3d0ade76 100644 --- a/src/app/system/navigation/navigate.ts +++ b/src/app/system/navigation/navigate.ts @@ -93,13 +93,16 @@ export async function navigate(url: string, options: NavigateOptions = {}) { } else { if (module.options.onlyShowInTabName) { switchTab(module.options.onlyShowInTabName) - // We wait for a frame to allow the tab to be switched before we navigate - // This allows us to also override the back button behavior in the tab - requestAnimationFrame(() => { - internal_navigationRef.current?.dispatch( - StackActions.push(result.module, { ...result.params, ...options.passProps }) - ) - }) + + if (!module.options.isRootViewForTabName) { + // We wait for a frame to allow the tab to be switched before we navigate + // This allows us to also override the back button behavior in the tab + requestAnimationFrame(() => { + internal_navigationRef.current?.dispatch( + StackActions.push(result.module, { ...result.params, ...options.passProps }) + ) + }) + } } else { internal_navigationRef.current?.dispatch( StackActions.push(result.module, { ...result.params, ...options.passProps }) diff --git a/src/app/system/navigation/routes.tests.ts b/src/app/system/navigation/routes.tests.ts index 3e5a33220db..0bed01b33cf 100644 --- a/src/app/system/navigation/routes.tests.ts +++ b/src/app/system/navigation/routes.tests.ts @@ -671,6 +671,7 @@ describe("artsy.net routes", () => { "module": "ModalWebView", "params": { "alwaysPresentModally": true, + "isPresentedModally": true, "url": "/terms", }, "type": "match", @@ -684,6 +685,7 @@ describe("artsy.net routes", () => { "module": "ModalWebView", "params": { "alwaysPresentModally": true, + "isPresentedModally": true, "url": "/privacy", }, "type": "match", @@ -696,6 +698,7 @@ describe("artsy.net routes", () => { { "module": "ReactWebView", "params": { + "isPresentedModally": false, "url": "/unsubscribe", }, "type": "match", @@ -870,6 +873,7 @@ describe("artsy.net routes", () => { "module": "ModalWebView", "params": { "alwaysPresentModally": true, + "isPresentedModally": true, "url": "/conditions-of-sale", }, "type": "match", @@ -1129,6 +1133,7 @@ describe("artsy.net routes", () => { { "module": "ReactWebView", "params": { + "isPresentedModally": false, "url": "/categories", }, "type": "match", @@ -1142,6 +1147,7 @@ describe("artsy.net routes", () => { "module": "ModalWebView", "params": { "alwaysPresentModally": true, + "isPresentedModally": true, "url": "/privacy", }, "type": "match", @@ -1184,6 +1190,7 @@ describe("artsy.net routes", () => { { "module": "ReactWebView", "params": { + "isPresentedModally": false, "url": "/the/mighty/boosh", }, "type": "match", @@ -1193,6 +1200,7 @@ describe("artsy.net routes", () => { { "module": "ReactWebView", "params": { + "isPresentedModally": false, "url": "/one-hundred/years-of/solitude", }, "type": "match", @@ -1249,12 +1257,16 @@ describe("addWebViewRoute", () => { it("returns a route matcher for web views", () => { const matcher = addWebViewRoute("/conditions-of-sale") expect(matcher.module).toBe("ReactWebView") - expect(matcher.match(["conditions-of-sale"])).toEqual({ url: "/conditions-of-sale" }) + expect(matcher.match(["conditions-of-sale"])).toEqual({ + isPresentedModally: false, + url: "/conditions-of-sale", + }) }) it("inlines params and wildcards in the original route", () => { const matcher = addWebViewRoute("/artist/:artistID/*") expect(matcher.match(["artist", "banksy", "auction-results", "8907"])).toEqual({ + isPresentedModally: false, url: "/artist/banksy/auction-results/8907", }) }) @@ -1262,6 +1274,7 @@ describe("addWebViewRoute", () => { it("inlines params in the original order history route", () => { const matcher = addWebViewRoute("/user/purchases/:orderID") expect(matcher.match(["user", "purchases", "8907"])).toEqual({ + isPresentedModally: false, url: "/user/purchases/8907", }) }) @@ -1269,6 +1282,7 @@ describe("addWebViewRoute", () => { it("inlines params in the original article route", () => { const matcher = addWebViewRoute("/article/:orderID") expect(matcher.match(["article", "article-article"])).toEqual({ + isPresentedModally: false, url: "/article/article-article", }) })