Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c6b9fd35
Unverified
Commit
c6b9fd35
authored
Oct 22, 2026
by
Jiachi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix navigation from global-not-found to app routes
parent
50bf604f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
render-tree.ts
packages/next/src/client/components/render-tree.ts
+3
-2
global-not-found.tsx
...e/app-dir/global-not-found/basic/app/global-not-found.tsx
+2
-0
global-not-found-basic.test.ts
...dir/global-not-found/basic/global-not-found-basic.test.ts
+12
-0
No files found.
packages/next/src/client/components/render-tree.ts
View file @
c6b9fd35
...
@@ -363,13 +363,14 @@ function updateRenderTreeOnNavigation(
...
@@ -363,13 +363,14 @@ function updateRenderTreeOnNavigation(
// case, because it acts like a root layout, but in the router tree, it
// case, because it acts like a root layout, but in the router tree, it
// is rendered in the same position as app/layout.tsx.
// is rendered in the same position as app/layout.tsx.
//
//
// Any navigation to the global Not Found route should trigger a
// Any navigation to
or from
the global Not Found route should trigger a
// full-page navigation.
// full-page navigation.
//
//
// TODO: We should probably model this by changing the key of the root
// TODO: We should probably model this by changing the key of the root
// segment when this happens. Then the root layout check would work
// segment when this happens. Then the root layout check would work
// as expected, without a special case.
// as expected, without a special case.
newSegment
===
NOT_FOUND_SEGMENT_KEY
newSegment
===
NOT_FOUND_SEGMENT_KEY
||
oldRenderTree
.
segment
===
NOT_FOUND_SEGMENT_KEY
)
{
)
{
return
null
return
null
}
}
...
...
test/e2e/app-dir/global-not-found/basic/app/global-not-found.tsx
View file @
c6b9fd35
import
{
Client
}
from
'./client'
import
{
Client
}
from
'./client'
import
Link
from
'next/link'
export
default
function
GlobalNotFound
()
{
export
default
function
GlobalNotFound
()
{
return
(
return
(
...
@@ -7,6 +8,7 @@ export default function GlobalNotFound() {
...
@@ -7,6 +8,7 @@ export default function GlobalNotFound() {
<
body
>
<
body
>
<
h1
id=
"global-error-title"
>
global-not-found
</
h1
>
<
h1
id=
"global-error-title"
>
global-not-found
</
h1
>
<
Client
/>
<
Client
/>
<
Link
href=
"/"
>
Return home
</
Link
>
</
body
>
</
body
>
</
html
>
</
html
>
)
)
...
...
test/e2e/app-dir/global-not-found/basic/global-not-found-basic.test.ts
View file @
c6b9fd35
...
@@ -28,6 +28,18 @@ describe('global-not-found - basic', () => {
...
@@ -28,6 +28,18 @@ describe('global-not-found - basic', () => {
expect
(
notFoundHtmlProp
).
toBe
(
'true'
)
expect
(
notFoundHtmlProp
).
toBe
(
'true'
)
})
})
it
(
'should navigate from global-not-found to the app root layout'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/does-not-exist'
)
await
browser
.
elementByCss
(
'a[href="/"]'
).
click
()
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'hello world'
)
expect
(
await
browser
.
elementByCss
(
'html'
).
getAttribute
(
'lang'
)).
toBe
(
'en'
)
expect
(
await
browser
.
elementByCss
(
'html'
).
getAttribute
(
'data-global-not-found'
)
).
toBeNull
()
})
it
(
'should render not-found boundary when calling notFound() in a page'
,
async
()
=>
{
it
(
'should render not-found boundary when calling notFound() in a page'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/call-not-found'
)
const
browser
=
await
next
.
browser
(
'/call-not-found'
)
// Still using the root layout
// Still using the root layout
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment