diff --git a/dotcom-rendering/src/components/Island.test.tsx b/dotcom-rendering/src/components/Island.test.tsx index dad418c6b11..e670fbd1752 100644 --- a/dotcom-rendering/src/components/Island.test.tsx +++ b/dotcom-rendering/src/components/Island.test.tsx @@ -267,6 +267,7 @@ describe('Island: server-side rendering', () => { enhanceTweetsSwitch={false} onFirstPage={true} webURL="" + renderingTarget="Web" mostRecentBlockId="" hasPinnedPost={false} />, diff --git a/dotcom-rendering/src/components/Liveness.importable.tsx b/dotcom-rendering/src/components/Liveness.importable.tsx index c917f5c3af0..62970f28eb4 100644 --- a/dotcom-rendering/src/components/Liveness.importable.tsx +++ b/dotcom-rendering/src/components/Liveness.importable.tsx @@ -5,6 +5,7 @@ import { getEmotionCache } from '../client/islands/emotion'; import { initHydration } from '../client/islands/initHydration'; import { useApi } from '../lib/useApi'; import type { LiveUpdateType } from '../types/liveBlog'; +import type { RenderingTarget } from '../types/renderingTarget'; import { Toast } from './Toast'; type Props = { @@ -17,6 +18,7 @@ type Props = { webURL: string; mostRecentBlockId: string; hasPinnedPost: boolean; + renderingTarget: RenderingTarget; }; /** @@ -154,6 +156,7 @@ export const Liveness = ({ webURL, mostRecentBlockId, hasPinnedPost, + renderingTarget, }: Props) => { const [showToast, setShowToast] = useState(false); const [topOfBlogVisible, setTopOfBlogVisible] = useState(); @@ -309,9 +312,15 @@ export const Liveness = ({ revealPendingBlocks(); setNumHiddenBlocks(0); } else { - window.location.href = `${webURL}#${placeToScrollTo}`; + const url = new URL(webURL); + if (renderingTarget === 'Apps') { + url.searchParams.set('dcr', 'apps'); + } + url.hash = placeToScrollTo; + + window.location.href = url.href; } - }, [hasPinnedPost, onFirstPage, webURL]); + }, [hasPinnedPost, onFirstPage, webURL, renderingTarget]); if (toastRoot && showToast) { /** diff --git a/dotcom-rendering/src/layouts/LiveLayout.tsx b/dotcom-rendering/src/layouts/LiveLayout.tsx index 134070c2db0..d751b02c4c8 100644 --- a/dotcom-rendering/src/layouts/LiveLayout.tsx +++ b/dotcom-rendering/src/layouts/LiveLayout.tsx @@ -614,6 +614,7 @@ export const LiveLayout = (props: WebProps | AppsProps) => { } onFirstPage={pagination.currentPage === 1} webURL={article.webURL} + renderingTarget={renderingTarget} // We default to string here because the property is optional but we // know it will exist for all blogs mostRecentBlockId={