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
c54cc019
Unverified
Commit
c54cc019
authored
Jun 23, 2025
by
Jiachi Liu
Committed by
GitHub
Jun 23, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[segment explorer] display default page in segment explorer (#80716)
parent
8324d810
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
93 additions
and
6 deletions
+93
-6
segment-explorer.tsx
...ools/dev-overlay/components/overview/segment-explorer.tsx
+2
-1
create-component-tree.tsx
...ages/next/src/server/app-render/create-component-tree.tsx
+11
-5
page.tsx
test/development/app-dir/segment-explorer/app/page.tsx
+2
-0
default.tsx
...ir/segment-explorer/app/parallel-default/@bar/default.tsx
+3
-0
layout.tsx
...dir/segment-explorer/app/parallel-default/@bar/layout.tsx
+8
-0
page.tsx
...p-dir/segment-explorer/app/parallel-default/@bar/page.tsx
+3
-0
page.tsx
...ment-explorer/app/parallel-default/@bar/subroute/page.tsx
+3
-0
default.tsx
...ir/segment-explorer/app/parallel-default/@foo/default.tsx
+3
-0
layout.tsx
...dir/segment-explorer/app/parallel-default/@foo/layout.tsx
+8
-0
page.tsx
...p-dir/segment-explorer/app/parallel-default/@foo/page.tsx
+3
-0
default.tsx
...app-dir/segment-explorer/app/parallel-default/default.tsx
+3
-0
layout.tsx
.../app-dir/segment-explorer/app/parallel-default/layout.tsx
+24
-0
page.tsx
...nt/app-dir/segment-explorer/app/parallel-default/page.tsx
+3
-0
segment-explorer.test.ts
...lopment/app-dir/segment-explorer/segment-explorer.test.ts
+17
-0
No files found.
packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.tsx
View file @
c54cc019
...
@@ -242,7 +242,8 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
...
@@ -242,7 +242,8 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
user-select: none;
user-select: none;
}
}
.segment-explorer-file-label--layout,
.segment-explorer-file-label--layout,
.segment-explorer-file-label--template {
.segment-explorer-file-label--template,
.segment-explorer-file-label--default {
background-color: var(--color-gray-300);
background-color: var(--color-gray-300);
color: var(--color-gray-1000);
color: var(--color-gray-1000);
}
}
...
...
packages/next/src/server/app-render/create-component-tree.tsx
View file @
c54cc019
...
@@ -25,6 +25,7 @@ import type {
...
@@ -25,6 +25,7 @@ import type {
UseCacheLayoutComponentProps
,
UseCacheLayoutComponentProps
,
UseCachePageComponentProps
,
UseCachePageComponentProps
,
}
from
'../use-cache/use-cache-wrapper'
}
from
'../use-cache/use-cache-wrapper'
import
{
DEFAULT_SEGMENT_KEY
}
from
'../../shared/lib/segment'
/**
/**
* Use the provided loader tree to create the React Component tree.
* Use the provided loader tree to create the React Component tree.
...
@@ -431,8 +432,6 @@ async function createComponentTreeInternal({
...
@@ -431,8 +432,6 @@ async function createComponentTreeInternal({
tree
,
tree
,
})
})
const
nodeName
=
modType
??
'page'
// TODO: Combine this `map` traversal with the loop below that turns the array
// TODO: Combine this `map` traversal with the loop below that turns the array
// into an object.
// into an object.
const
parallelRouteMap
=
await
Promise
.
all
(
const
parallelRouteMap
=
await
Promise
.
all
(
...
@@ -743,10 +742,16 @@ async function createComponentTreeInternal({
...
@@ -743,10 +742,16 @@ async function createComponentTreeInternal({
}
}
}
}
const
pageFilePath
=
getConventionPathByType
(
tree
,
dir
,
'page'
)
const
isDefaultSegment
=
segment
===
DEFAULT_SEGMENT_KEY
const
pageFilePath
=
getConventionPathByType
(
tree
,
dir
,
'page'
)
??
getConventionPathByType
(
tree
,
dir
,
'defaultPage'
)
const
wrappedPageElement
=
const
wrappedPageElement
=
isSegmentViewEnabled
&&
pageFilePath
?
(
isSegmentViewEnabled
&&
pageFilePath
?
(
<
SegmentViewNode
type=
{
nodeName
}
pagePath=
{
pageFilePath
}
>
<
SegmentViewNode
type=
{
isDefaultSegment
?
'default'
:
'page'
}
pagePath=
{
pageFilePath
}
>
{
pageElement
}
{
pageElement
}
</
SegmentViewNode
>
</
SegmentViewNode
>
)
:
(
)
:
(
...
@@ -931,7 +936,7 @@ async function createComponentTreeInternal({
...
@@ -931,7 +936,7 @@ async function createComponentTreeInternal({
const
layoutFilePath
=
getConventionPathByType
(
tree
,
dir
,
'layout'
)
const
layoutFilePath
=
getConventionPathByType
(
tree
,
dir
,
'layout'
)
const
wrappedSegmentNode
=
const
wrappedSegmentNode
=
isSegmentViewEnabled
&&
layoutFilePath
?
(
isSegmentViewEnabled
&&
layoutFilePath
?
(
<
SegmentViewNode
type=
{
nodeName
}
pagePath=
{
layoutFilePath
}
>
<
SegmentViewNode
type=
"layout"
pagePath=
{
layoutFilePath
}
>
{
segmentNode
}
{
segmentNode
}
</
SegmentViewNode
>
</
SegmentViewNode
>
)
:
(
)
:
(
...
@@ -1136,6 +1141,7 @@ function getConventionPathByType(
...
@@ -1136,6 +1141,7 @@ function getConventionPathByType(
|
'loading'
|
'loading'
|
'forbidden'
|
'forbidden'
|
'unauthorized'
|
'unauthorized'
|
'defaultPage'
)
{
)
{
const
modules
=
tree
[
2
]
const
modules
=
tree
[
2
]
const
conventionPath
=
modules
[
conventionType
]
const
conventionPath
=
modules
[
conventionType
]
...
...
test/development/app-dir/segment-explorer/app/page.tsx
View file @
c54cc019
...
@@ -5,6 +5,8 @@ const hrefs = [
...
@@ -5,6 +5,8 @@ const hrefs = [
'/blog/~/grid'
,
'/blog/~/grid'
,
'/soft-navigation/a'
,
'/soft-navigation/a'
,
'/file-segments'
,
'/file-segments'
,
'/parallel-default'
,
'/parallel-default/subroute'
,
]
]
export
default
function
Page
()
{
export
default
function
Page
()
{
...
...
test/development/app-dir/segment-explorer/app/parallel-default/@bar/default.tsx
0 → 100644
View file @
c54cc019
export
default
function
Default
()
{
return
'@bar default'
}
test/development/app-dir/segment-explorer/app/parallel-default/@bar/layout.tsx
0 → 100644
View file @
c54cc019
export
default
function
Layout
({
children
})
{
return
(
<
div
>
<
h1
>
@bar Layout
</
h1
>
<
div
id=
"bar-children"
>
{
children
}
</
div
>
</
div
>
)
}
test/development/app-dir/segment-explorer/app/parallel-default/@bar/page.tsx
0 → 100644
View file @
c54cc019
export
default
function
Page
()
{
return
<
div
>
Bar Slot
</
div
>
}
test/development/app-dir/segment-explorer/app/parallel-default/@bar/subroute/page.tsx
0 → 100644
View file @
c54cc019
export
default
function
Page
()
{
return
<
div
>
Subroute
</
div
>
}
test/development/app-dir/segment-explorer/app/parallel-default/@foo/default.tsx
0 → 100644
View file @
c54cc019
export
default
function
Default
()
{
return
'@foo default'
}
test/development/app-dir/segment-explorer/app/parallel-default/@foo/layout.tsx
0 → 100644
View file @
c54cc019
export
default
function
Layout
({
children
})
{
return
(
<
div
>
<
h1
>
@foo Layout
</
h1
>
<
div
id=
"foo-children"
>
{
children
}
</
div
>
</
div
>
)
}
test/development/app-dir/segment-explorer/app/parallel-default/@foo/page.tsx
0 → 100644
View file @
c54cc019
export
default
function
Page
()
{
return
<
div
>
Foo Slot
</
div
>
}
test/development/app-dir/segment-explorer/app/parallel-default/default.tsx
0 → 100644
View file @
c54cc019
export
default
function
Page
()
{
return
'default page'
}
test/development/app-dir/segment-explorer/app/parallel-default/layout.tsx
0 → 100644
View file @
c54cc019
import
Link
from
'next/link'
export
default
function
Layout
({
children
,
bar
,
foo
})
{
return
(
<
div
>
<
h1
>
Nested Layout
</
h1
>
<
div
>
<
div
>
<
Link
href=
"/parallel-default/subroute"
>
<
div
id=
"subroute-link"
>
Go to /parallel-default/subroute
</
div
>
</
Link
>
</
div
>
<
div
>
<
Link
href=
"/parallel-default"
>
<
div
id=
"grid-link"
>
Go to /parallel-default
</
div
>
</
Link
>
</
div
>
</
div
>
<
div
id=
"nested-children"
>
{
children
}
</
div
>
<
div
id=
"foo-slot"
>
{
foo
}
</
div
>
<
div
id=
"bar-slot"
>
{
bar
}
</
div
>
</
div
>
)
}
test/development/app-dir/segment-explorer/app/parallel-default/page.tsx
0 → 100644
View file @
c54cc019
export
default
function
Page
()
{
return
<
div
>
Hello from Nested
</
div
>
}
test/development/app-dir/segment-explorer/segment-explorer.test.ts
View file @
c54cc019
...
@@ -189,4 +189,21 @@ describe('segment-explorer', () => {
...
@@ -189,4 +189,21 @@ describe('segment-explorer', () => {
error.tsx"
error.tsx"
`
)
`
)
})
})
it
(
'should display parallel routes default page when present'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/parallel-default/subroute'
)
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
parallel-default/
layout.tsx
default.tsx
@bar/
layout.tsx
subroute/
page.tsx
@foo/
default.tsx"
`
)
})
})
})
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