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
b5f2517a
Unverified
Commit
b5f2517a
authored
Jul 14, 2025
by
Jiachi Liu
Committed by
GitHub
Jul 14, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[segment explorer] fix boundary trigger state (#81623)
parent
d04d65b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
43 deletions
+16
-43
segment-boundary-trigger.css
...-overlay/components/overview/segment-boundary-trigger.css
+0
-9
segment-boundary-trigger.tsx
...-overlay/components/overview/segment-boundary-trigger.tsx
+14
-25
segment-explorer.tsx
...ools/dev-overlay/components/overview/segment-explorer.tsx
+2
-9
No files found.
packages/next/src/next-devtools/dev-overlay/components/overview/segment-boundary-trigger.css
View file @
b5f2517a
...
@@ -47,15 +47,6 @@
...
@@ -47,15 +47,6 @@
cursor
:
not-allowed
;
cursor
:
not-allowed
;
}
}
.segment-boundary-trigger--boundary
{
background
:
var
(
--color-background-100
);
box-shadow
:
inset
0
0
0
1px
var
(
--color-gray-400
);
}
.segment-boundary-trigger--boundary
:hover
{
background
:
var
(
--color-gray-200
);
}
.segment-boundary-dropdown
{
.segment-boundary-dropdown
{
padding
:
8px
;
padding
:
8px
;
background
:
var
(
--color-background-100
);
background
:
var
(
--color-background-100
);
...
...
packages/next/src/next-devtools/dev-overlay/components/overview/segment-boundary-trigger.tsx
View file @
b5f2517a
...
@@ -2,11 +2,7 @@ import './segment-boundary-trigger.css'
...
@@ -2,11 +2,7 @@ import './segment-boundary-trigger.css'
import
{
useCallback
,
useState
,
useRef
,
useMemo
}
from
'react'
import
{
useCallback
,
useState
,
useRef
,
useMemo
}
from
'react'
import
{
Menu
}
from
'@base-ui-components/react/menu'
import
{
Menu
}
from
'@base-ui-components/react/menu'
import
type
{
SegmentNodeState
}
from
'../../../userspace/app/segment-explorer-node'
import
type
{
SegmentNodeState
}
from
'../../../userspace/app/segment-explorer-node'
import
{
import
{
normalizeBoundaryFilename
}
from
'../../../../server/app-render/segment-explorer-path'
isBoundaryFile
,
normalizeBoundaryFilename
,
}
from
'../../../../server/app-render/segment-explorer-path'
import
{
cx
}
from
'../../utils/cx'
import
{
useClickOutside
}
from
'../errors/dev-tools-indicator/utils'
import
{
useClickOutside
}
from
'../errors/dev-tools-indicator/utils'
const
composeRefs
=
(...
refs
:
(
React
.
Ref
<
HTMLButtonElement
>
|
undefined
)[])
=>
{
const
composeRefs
=
(...
refs
:
(
React
.
Ref
<
HTMLButtonElement
>
|
undefined
)[])
=>
{
...
@@ -29,13 +25,7 @@ export function SegmentBoundaryTrigger({
...
@@ -29,13 +25,7 @@ export function SegmentBoundaryTrigger({
boundaries
:
Record
<
'not-found'
|
'loading'
|
'error'
,
string
|
null
>
boundaries
:
Record
<
'not-found'
|
'loading'
|
'error'
,
string
|
null
>
})
{
})
{
const
currNode
=
nodeState
const
currNode
=
nodeState
const
{
const
{
pagePath
,
boundaryType
,
setBoundaryType
:
onSelectBoundary
}
=
currNode
pagePath
,
boundaryType
,
type
,
setBoundaryType
:
onSelectBoundary
,
}
=
currNode
const
fileType
=
type
const
[
isOpen
,
setIsOpen
]
=
useState
(
false
)
const
[
isOpen
,
setIsOpen
]
=
useState
(
false
)
// TODO: move this shadowRoot ref util to a shared hook or into context
// TODO: move this shadowRoot ref util to a shared hook or into context
...
@@ -76,15 +66,12 @@ export function SegmentBoundaryTrigger({
...
@@ -76,15 +66,12 @@ export function SegmentBoundaryTrigger({
},
[
boundaries
,
possibleExtension
])
},
[
boundaries
,
possibleExtension
])
const
fileName
=
(
pagePath
||
''
).
split
(
'/'
).
pop
()
||
''
const
fileName
=
(
pagePath
||
''
).
split
(
'/'
).
pop
()
||
''
const
isBoundary
=
isBoundaryFile
(
fileType
)
const
pageFileName
=
normalizeBoundaryFilename
(
const
pageFileName
=
normalizeBoundaryFilename
(
boundaryType
boundaryType
?
`page.
${
possibleExtension
}
`
?
`page.
${
possibleExtension
}
`
:
fileName
||
`page.
${
possibleExtension
}
`
:
fileName
||
`page.
${
possibleExtension
}
`
)
)
const
isPageOrBoundary
=
fileType
&&
!
isBoundary
const
triggerOptions
=
[
const
triggerOptions
=
[
{
{
label
:
fileNames
.
loading
,
label
:
fileNames
.
loading
,
...
@@ -158,15 +145,21 @@ export function SegmentBoundaryTrigger({
...
@@ -158,15 +145,21 @@ export function SegmentBoundaryTrigger({
return
<
Trigger
{
...
triggerProps
}
ref=
{
mergedRef
}
/>
return
<
Trigger
{
...
triggerProps
}
ref=
{
mergedRef
}
/>
}
}
const
hasBoundary
=
useMemo
(()
=>
{
const
hasPageOrBoundary
=
nodeState
.
type
!==
'layout'
&&
nodeState
.
type
!==
'template'
return
(
hasPageOrBoundary
&&
Object
.
values
(
boundaries
).
some
((
v
)
=>
v
!==
null
)
)
},
[
nodeState
.
type
,
boundaries
])
return
(
return
(
<
Menu
.
Root
delay=
{
0
}
modal=
{
false
}
open=
{
isOpen
}
onOpenChange=
{
setIsOpen
}
>
<
Menu
.
Root
delay=
{
0
}
modal=
{
false
}
open=
{
isOpen
}
onOpenChange=
{
setIsOpen
}
>
<
Menu
.
Trigger
<
Menu
.
Trigger
className=
{
cx
(
className=
"segment-boundary-trigger"
'segment-boundary-trigger'
,
!
isPageOrBoundary
&&
'segment-boundary-trigger--boundary'
)
}
data
-
nextjs
-
dev
-
overlay
-
segment
-
boundary
-
trigger
-
button
data
-
nextjs
-
dev
-
overlay
-
segment
-
boundary
-
trigger
-
button
render=
{
MergedRefTrigger
}
render=
{
MergedRefTrigger
}
disabled=
{
!
hasBoundary
}
/>
/>
{
/* @ts-expect-error remove this expect-error once shadowRoot is supported as container */
}
{
/* @ts-expect-error remove this expect-error once shadowRoot is supported as container */
}
...
@@ -330,13 +323,9 @@ function SwitchIcon(props: React.SVGProps<SVGSVGElement>) {
...
@@ -330,13 +323,9 @@ function SwitchIcon(props: React.SVGProps<SVGSVGElement>) {
)
)
}
}
export
function
Trigger
(
props
:
React
.
ComponentProps
<
'button'
>
)
{
function
Trigger
(
props
:
React
.
ComponentProps
<
'button'
>
)
{
return
(
return
(
<
button
<
button
{
...
props
}
>
{
...
props
}
className=
{
cx
(
'segment-boundary-trigger'
,
props
.
className
)
}
role=
"button"
>
<
span
className=
"segment-boundary-trigger-text"
>
<
span
className=
"segment-boundary-trigger-text"
>
<
SwitchIcon
className=
"plus-icon"
/>
<
SwitchIcon
className=
"plus-icon"
/>
</
span
>
</
span
>
...
...
packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.tsx
View file @
b5f2517a
...
@@ -4,7 +4,7 @@ import {
...
@@ -4,7 +4,7 @@ import {
type
SegmentTrieNode
,
type
SegmentTrieNode
,
}
from
'../../segment-explorer-trie'
}
from
'../../segment-explorer-trie'
import
{
cx
}
from
'../../utils/cx'
import
{
cx
}
from
'../../utils/cx'
import
{
SegmentBoundaryTrigger
,
Trigger
}
from
'./segment-boundary-trigger'
import
{
SegmentBoundaryTrigger
}
from
'./segment-boundary-trigger'
import
{
Tooltip
}
from
'../../../components/tooltip'
import
{
Tooltip
}
from
'../../../components/tooltip'
import
{
useCallback
,
useMemo
}
from
'react'
import
{
useCallback
,
useMemo
}
from
'react'
import
{
import
{
...
@@ -257,12 +257,6 @@ function PageSegmentTreeLayerPresentation({
...
@@ -257,12 +257,6 @@ function PageSegmentTreeLayerPresentation({
const
filesChildrenKeysBesidesSelectedBoundary
=
filesChildrenKeys
const
filesChildrenKeysBesidesSelectedBoundary
=
filesChildrenKeys
const
isChildPageOrBoundary
=
firstChild
&&
firstChild
.
value
&&
firstChild
.
value
.
type
!==
'layout'
&&
firstChild
.
value
.
type
!==
'template'
return
(
return
(
<>
<>
{
hasFilesChildren
&&
(
{
hasFilesChildren
&&
(
...
@@ -359,13 +353,12 @@ function PageSegmentTreeLayerPresentation({
...
@@ -359,13 +353,12 @@ function PageSegmentTreeLayerPresentation({
)
}
)
}
</
span
>
</
span
>
)
}
)
}
{
firstChild
&&
firstChild
.
value
&&
isChildPageOrBoundary
&&
(
{
firstChild
&&
firstChild
.
value
&&
(
<
SegmentBoundaryTrigger
<
SegmentBoundaryTrigger
nodeState=
{
firstChild
.
value
}
nodeState=
{
firstChild
.
value
}
boundaries=
{
boundaries
}
boundaries=
{
boundaries
}
/>
/>
)
}
)
}
{
!
isChildPageOrBoundary
&&
<
Trigger
disabled
/>
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
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