Skip to content

Commit 8fc898d

Browse files
committed
add new test case for parallel routes
1 parent a881e56 commit 8fc898d

File tree

14 files changed

+118
-0
lines changed

14 files changed

+118
-0
lines changed

packages/next/src/client/components/router-reducer/reducers/find-head-in-cache.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { FlightRouterState } from '../../../../server/app-render/types'
22
import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'
3+
import { DEFAULT_SEGMENT_KEY } from '../../../../shared/lib/segment'
34
import { createRouterCacheKey } from '../create-router-cache-key'
45

56
export function findHeadInCache(
@@ -34,6 +35,11 @@ function findHeadInCacheImpl(
3435
// if we didn't find metadata in the page slot, check the other parallel routes
3536
for (const key of parallelRoutesKeys) {
3637
const [segment, childParallelRoutes] = parallelRoutes[key]
38+
// If the parallel is not matched and using the default segment,
39+
// skip searching the head from it.
40+
if (segment === DEFAULT_SEGMENT_KEY) {
41+
continue
42+
}
3743
const childSegmentMap = cache.parallelRoutes.get(key)
3844
if (!childSegmentMap) {
3945
continue

test/e2e/app-dir/metadata-streaming-parallel-routes/app/layout.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export default function Root({ children }: { children: ReactNode }) {
1414
{`to /parallel-routes-default`}
1515
</Link>
1616
<br />
17+
18+
<Link href="/parallel-routes-no-children" id="to-no-children">
19+
{`to /parallel-routes-no-children`}
20+
</Link>
21+
<br />
1722
</div>
1823
{children}
1924
</body>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return 'default @bar'
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function Page() {
2+
return <p id="bar-page">test-page @bar - 1</p>
3+
}
4+
5+
export const metadata = {
6+
title: 'first page - @bar',
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function Layout({ children }) {
2+
return (
3+
<div>
4+
<h2>@bar Layout</h2>
5+
<div id="bar-children">{children}</div>
6+
</div>
7+
)
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return 'page @bar'
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function Page() {
2+
return <p id="bar-page">test-page @bar - 2</p>
3+
}
4+
5+
export const metadata = {
6+
title: 'second page - @bar',
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return 'default @foo'
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function Layout({ children }) {
2+
return (
3+
<div>
4+
<h2>@foo Layout</h2>
5+
<div id="foo-children">{children}</div>
6+
</div>
7+
)
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return 'no-bar @foo'
3+
}

0 commit comments

Comments
 (0)