Skip to content

Commit b574910

Browse files
authored
Merge pull request #15000 from guardian/fix-bug-in-liveness
Liveblog updates in Apps should stay in Apps
2 parents 42236e6 + 673484b commit b574910

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

dotcom-rendering/src/components/Island.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ describe('Island: server-side rendering', () => {
267267
enhanceTweetsSwitch={false}
268268
onFirstPage={true}
269269
webURL=""
270+
renderingTarget="Web"
270271
mostRecentBlockId=""
271272
hasPinnedPost={false}
272273
/>,

dotcom-rendering/src/components/Liveness.importable.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getEmotionCache } from '../client/islands/emotion';
55
import { initHydration } from '../client/islands/initHydration';
66
import { useApi } from '../lib/useApi';
77
import type { LiveUpdateType } from '../types/liveBlog';
8+
import type { RenderingTarget } from '../types/renderingTarget';
89
import { Toast } from './Toast';
910

1011
type Props = {
@@ -17,6 +18,7 @@ type Props = {
1718
webURL: string;
1819
mostRecentBlockId: string;
1920
hasPinnedPost: boolean;
21+
renderingTarget: RenderingTarget;
2022
};
2123

2224
/**
@@ -154,6 +156,7 @@ export const Liveness = ({
154156
webURL,
155157
mostRecentBlockId,
156158
hasPinnedPost,
159+
renderingTarget,
157160
}: Props) => {
158161
const [showToast, setShowToast] = useState(false);
159162
const [topOfBlogVisible, setTopOfBlogVisible] = useState<boolean>();
@@ -309,9 +312,15 @@ export const Liveness = ({
309312
revealPendingBlocks();
310313
setNumHiddenBlocks(0);
311314
} else {
312-
window.location.href = `${webURL}#${placeToScrollTo}`;
315+
const url = new URL(webURL);
316+
if (renderingTarget === 'Apps') {
317+
url.searchParams.set('dcr', 'apps');
318+
}
319+
url.hash = placeToScrollTo;
320+
321+
window.location.href = url.href;
313322
}
314-
}, [hasPinnedPost, onFirstPage, webURL]);
323+
}, [hasPinnedPost, onFirstPage, webURL, renderingTarget]);
315324

316325
if (toastRoot && showToast) {
317326
/**

dotcom-rendering/src/layouts/LiveLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
614614
}
615615
onFirstPage={pagination.currentPage === 1}
616616
webURL={article.webURL}
617+
renderingTarget={renderingTarget}
617618
// We default to string here because the property is optional but we
618619
// know it will exist for all blogs
619620
mostRecentBlockId={

0 commit comments

Comments
 (0)