-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PPR Nav] Fix: Page data should always be applied (#60242)
This fixes a case in the PPR navigations implementation where page data was not being applied. During a navigation, we compare the route trees of the old and new pages to determine which layouts are shared. If the segment keys of two layouts are the same, they are reused. However, the server doesn't bother to assign segment keys to the leaf segments (which we refer to as "page" segments) because they are never part of a shared layout. It assigns all of them a special constant (`__PAGE__`). In the PPR implementation, I overlooked this and compared the segment keys of all segments, including pages, not just shared layouts. So if the only thing that changed during a navigation was the page data, and not any parent layout, the client would fail to apply the navigation. The fix is to add a special case for page segments before comparing nested layouts. I also moved an existing special case for default pages, since those are also leaf segments and are conceptually similar.
- Loading branch information
Showing
5 changed files
with
106 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/ppr-navigations/search-params/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Root({ children }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
test/e2e/app-dir/ppr-navigations/search-params/app/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Link from 'next/link' | ||
|
||
export default async function Page({ | ||
searchParams, | ||
}: { | ||
searchParams: { [key: string]: string | string[] | undefined } | ||
}) { | ||
const hasParams = Object.keys(searchParams).length > 0 | ||
return ( | ||
<> | ||
<Link href="/?blazing=good">Go</Link> | ||
{hasParams ? ( | ||
<div id="search-params"> | ||
Search params: {JSON.stringify(searchParams)} | ||
</div> | ||
) : null} | ||
</> | ||
) | ||
} |
10 changes: 10 additions & 0 deletions
10
test/e2e/app-dir/ppr-navigations/search-params/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
experimental: { | ||
ppr: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |