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
9d4239a1
Unverified
Commit
9d4239a1
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] handle display loading (#80698)
parent
04a900f7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
2 deletions
+96
-2
segment-explorer.tsx
...ools/dev-overlay/components/overview/segment-explorer.tsx
+4
-0
create-component-tree.tsx
...ages/next/src/server/app-render/create-component-tree.tsx
+14
-2
layout.tsx
...evelopment/app-dir/segment-explorer/app/search/layout.tsx
+13
-0
loading.tsx
...velopment/app-dir/segment-explorer/app/search/loading.tsx
+3
-0
page.tsx
.../development/app-dir/segment-explorer/app/search/page.tsx
+21
-0
search.tsx
...evelopment/app-dir/segment-explorer/app/search/search.tsx
+22
-0
segment-explorer.test.ts
...lopment/app-dir/segment-explorer/segment-explorer.test.ts
+19
-0
No files found.
packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.tsx
View file @
9d4239a1
...
@@ -256,4 +256,8 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
...
@@ -256,4 +256,8 @@ export const DEV_TOOLS_INFO_RENDER_FILES_STYLES = css`
background-color: var(--color-amber-300);
background-color: var(--color-amber-300);
color: var(--color-amber-900);
color: var(--color-amber-900);
}
}
.segment-explorer-file-label--loading {
background-color: var(--color-green-300);
color: var(--color-green-900);
}
`
`
packages/next/src/server/app-render/create-component-tree.tsx
View file @
9d4239a1
...
@@ -593,8 +593,20 @@ async function createComponentTreeInternal({
...
@@ -593,8 +593,20 @@ async function createComponentTreeInternal({
parallelRouteCacheNodeSeedData
[
parallelRouteKey
]
=
flightData
parallelRouteCacheNodeSeedData
[
parallelRouteKey
]
=
flightData
}
}
const
loadingData
:
LoadingModuleData
=
Loading
let
loadingElement
=
Loading
?
<
Loading
key=
"l"
/>
:
null
?
[<
Loading
key=
"l"
/>,
loadingStyles
,
loadingScripts
]
if
(
isSegmentViewEnabled
&&
loadingElement
)
{
const
loadingFilePath
=
getConventionPathByType
(
tree
,
dir
,
'loading'
)
if
(
loadingFilePath
)
{
loadingElement
=
(
<
SegmentViewNode
type=
"loading"
pagePath=
{
loadingFilePath
}
>
{
loadingElement
}
</
SegmentViewNode
>
)
}
}
const
loadingData
:
LoadingModuleData
=
loadingElement
?
[
loadingElement
,
loadingStyles
,
loadingScripts
]
:
null
:
null
// When the segment does not have a layout or page we still have to add the layout router to ensure the path holds the loading component
// When the segment does not have a layout or page we still have to add the layout router to ensure the path holds the loading component
...
...
test/development/app-dir/segment-explorer/app/search/layout.tsx
0 → 100644
View file @
9d4239a1
'use client'
import
{
Fragment
}
from
'react'
import
{
useSearchParams
}
from
'next/navigation'
export
default
function
SearchLayout
({
children
,
}:
{
children
:
React
.
ReactNode
})
{
let
searchParams
=
useSearchParams
()
return
<
Fragment
key=
{
searchParams
?.
get
(
'q'
)
}
>
{
children
}
</
Fragment
>
}
test/development/app-dir/segment-explorer/app/search/loading.tsx
0 → 100644
View file @
9d4239a1
export
default
function
Loading
()
{
return
<
p
id=
"loading"
>
Loading...
</
p
>
}
test/development/app-dir/segment-explorer/app/search/page.tsx
0 → 100644
View file @
9d4239a1
import
{
Search
}
from
'./search'
type
AnySearchParams
=
{
[
key
:
string
]:
string
|
Array
<
string
>
|
undefined
}
export
default
async
function
Page
({
searchParams
,
}:
{
searchParams
:
Promise
<
AnySearchParams
>
})
{
const
search
=
await
searchParams
if
(
Object
.
keys
(
search
).
length
>
0
)
{
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
30
*
1000
))
}
return
(
<
main
id=
"page-content"
>
<
Search
/>
<
p
id=
"search-value"
>
Search Value:
{
search
.
q
??
'None'
}
</
p
>
</
main
>
)
}
test/development/app-dir/segment-explorer/app/search/search.tsx
0 → 100644
View file @
9d4239a1
'use client'
import
{
useRouter
}
from
'next/navigation'
export
function
Search
()
{
let
router
=
useRouter
()
function
search
(
event
:
React
.
FormEvent
<
HTMLFormElement
>
)
{
event
.
preventDefault
()
let
input
=
event
.
currentTarget
.
q
.
value
let
params
=
new
URLSearchParams
([[
'q'
,
input
]])
router
.
push
(
`/search?
${
params
}
`
)
}
return
(
<
form
onSubmit=
{
search
}
>
<
input
placeholder=
"Search..."
name=
"q"
className=
"border"
/>
<
button
>
Submit
</
button
>
</
form
>
)
}
test/development/app-dir/segment-explorer/segment-explorer.test.ts
View file @
9d4239a1
...
@@ -160,4 +160,23 @@ describe('segment-explorer', () => {
...
@@ -160,4 +160,23 @@ describe('segment-explorer', () => {
unauthorized.tsx"
unauthorized.tsx"
`
)
`
)
})
})
it
(
'should show the loading boundary when it is present'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/search'
)
const
input
=
await
browser
.
elementByCss
(
'input[name="q"]'
)
await
input
.
fill
(
'abc'
)
await
browser
.
elementByCss
(
'button'
).
click
()
// submit the form
await
retry
(
async
()
=>
{
expect
(
await
browser
.
elementByCss
(
'#loading'
).
text
()).
toBe
(
'Loading...'
)
})
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
search/
layout.tsx
loading.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