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
684c7c01
Unverified
Commit
684c7c01
authored
Sep 05, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Sep 05, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[devtools] Use `useEffectEvent` instead of ignoring exhaustive deps (#83236)
parent
fe19e10c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
21 deletions
+34
-21
next-devtools.webpack-config.js
packages/next/next-devtools.webpack-config.js
+1
-1
resize-provider.tsx
...rlay/components/devtools-panel/resize/resize-provider.tsx
+15
-9
utils.ts
...ev-overlay/components/errors/dev-tools-indicator/utils.ts
+10
-8
dev-overlay-menu.tsx
...t/src/next-devtools/dev-overlay/menu/dev-overlay-menu.tsx
+8
-3
No files found.
packages/next/next-devtools.webpack-config.js
View file @
684c7c01
...
@@ -17,7 +17,7 @@ function shouldIgnorePath(modulePath) {
...
@@ -17,7 +17,7 @@ function shouldIgnorePath(modulePath) {
* @returns {webpack.Configuration}
* @returns {webpack.Configuration}
*/
*/
module
.
exports
=
({
dev
,
...
rest
})
=>
{
module
.
exports
=
({
dev
,
...
rest
})
=>
{
const
experimental
=
fals
e
const
experimental
=
tru
e
const
bundledReactChannel
=
experimental
?
'-experimental'
:
''
const
bundledReactChannel
=
experimental
?
'-experimental'
:
''
...
...
packages/next/src/next-devtools/dev-overlay/components/devtools-panel/resize/resize-provider.tsx
View file @
684c7c01
...
@@ -2,6 +2,7 @@ import {
...
@@ -2,6 +2,7 @@ import {
createContext
,
createContext
,
useCallback
,
useCallback
,
useContext
,
useContext
,
experimental_useEffectEvent
as
useEffectEvent
,
useLayoutEffect
,
useLayoutEffect
,
useState
,
useState
,
type
RefObject
,
type
RefObject
,
...
@@ -71,8 +72,9 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
...
@@ -71,8 +72,9 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
const
storageKey
=
value
.
storageKey
??
STORE_KEY_SHARED_PANEL_SIZE
const
storageKey
=
value
.
storageKey
??
STORE_KEY_SHARED_PANEL_SIZE
const
{
resizeRef
}
=
value
const
applyConstrainedDimensions
=
useCallback
(()
=>
{
const
applyConstrainedDimensions
=
useCallback
(()
=>
{
if
(
!
value
.
resizeRef
.
current
)
return
if
(
!
resizeRef
.
current
)
return
// this feels weird to read local storage on resize, but we don't
// this feels weird to read local storage on resize, but we don't
// track the dimensions of the container, and this is better than
// track the dimensions of the container, and this is better than
...
@@ -96,11 +98,11 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
...
@@ -96,11 +98,11 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
minHeight
:
minHeight
??
80
,
minHeight
:
minHeight
??
80
,
})
})
value
.
resizeRef
.
current
.
style
.
width
=
`
${
width
}
px`
resizeRef
.
current
.
style
.
width
=
`
${
width
}
px`
value
.
resizeRef
.
current
.
style
.
height
=
`
${
height
}
px`
resizeRef
.
current
.
style
.
height
=
`
${
height
}
px`
return
true
return
true
},
[
},
[
value
.
resizeRef
,
resizeRef
,
draggingDirection
,
draggingDirection
,
storageKey
,
storageKey
,
minWidth
,
minWidth
,
...
@@ -108,11 +110,11 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
...
@@ -108,11 +110,11 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
value
.
devToolsPanelSize
,
value
.
devToolsPanelSize
,
])
])
useLayoutEffec
t
(()
=>
{
const
fireInitialConstrainDimensions
=
useEffectEven
t
(()
=>
{
const
applied
=
applyConstrainedDimensions
()
const
applied
=
applyConstrainedDimensions
()
if
(
if
(
!
applied
&&
!
applied
&&
value
.
resizeRef
.
current
&&
resizeRef
.
current
&&
value
.
initialSize
?.
height
&&
value
.
initialSize
?.
height
&&
value
.
initialSize
.
width
value
.
initialSize
.
width
)
{
)
{
...
@@ -122,10 +124,14 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
...
@@ -122,10 +124,14 @@ export const ResizeProvider = ({ value, children }: ResizeProviderProps) => {
minWidth
:
minWidth
??
100
,
minWidth
:
minWidth
??
100
,
minHeight
:
minHeight
??
80
,
minHeight
:
minHeight
??
80
,
})
})
value
.
resizeRef
.
current
.
style
.
width
=
`
${
width
}
px`
resizeRef
.
current
.
style
.
width
=
`
${
width
}
px`
value
.
resizeRef
.
current
.
style
.
height
=
`
${
height
}
px`
resizeRef
.
current
.
style
.
height
=
`
${
height
}
px`
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
})
useLayoutEffect
(()
=>
{
// eslint-disable-next-line react-hooks/rules-of-hooks -- eprh bug
fireInitialConstrainDimensions
()
},
[])
},
[])
useLayoutEffect
(()
=>
{
useLayoutEffect
(()
=>
{
...
...
packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/utils.ts
View file @
684c7c01
import
{
useEffect
}
from
'react'
import
{
useEffect
,
experimental_useEffectEvent
as
useEffectEvent
}
from
'react'
export
function
useFocusTrap
(
export
function
useFocusTrap
(
rootRef
:
React
.
RefObject
<
HTMLElement
|
null
>
,
rootRef
:
React
.
RefObject
<
HTMLElement
|
null
>
,
...
@@ -6,6 +6,13 @@ export function useFocusTrap(
...
@@ -6,6 +6,13 @@ export function useFocusTrap(
active
:
boolean
,
active
:
boolean
,
onOpenFocus
?:
()
=>
void
onOpenFocus
?:
()
=>
void
)
{
)
{
const
fireOpenFocus
=
useEffectEvent
((
rootNode
:
HTMLElement
|
null
)
=>
{
if
(
onOpenFocus
)
{
onOpenFocus
()
}
else
{
rootNode
?.
focus
()
}
})
useEffect
(()
=>
{
useEffect
(()
=>
{
let
rootNode
:
HTMLElement
|
null
=
null
let
rootNode
:
HTMLElement
|
null
=
null
...
@@ -35,11 +42,7 @@ export function useFocusTrap(
...
@@ -35,11 +42,7 @@ export function useFocusTrap(
// Grab this on next tick to ensure the content is mounted
// Grab this on next tick to ensure the content is mounted
rootNode
=
rootRef
.
current
rootNode
=
rootRef
.
current
if
(
active
)
{
if
(
active
)
{
if
(
onOpenFocus
)
{
fireOpenFocus
(
rootNode
)
onOpenFocus
()
}
else
{
rootNode
?.
focus
()
}
rootNode
?.
addEventListener
(
'keydown'
,
onTab
)
rootNode
?.
addEventListener
(
'keydown'
,
onTab
)
}
else
{
}
else
{
const
activeElement
=
getActiveElement
(
rootNode
)
const
activeElement
=
getActiveElement
(
rootNode
)
...
@@ -56,8 +59,7 @@ export function useFocusTrap(
...
@@ -56,8 +59,7 @@ export function useFocusTrap(
clearTimeout
(
id
)
clearTimeout
(
id
)
rootNode
?.
removeEventListener
(
'keydown'
,
onTab
)
rootNode
?.
removeEventListener
(
'keydown'
,
onTab
)
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
active
,
rootRef
,
triggerRef
])
},
[
active
])
}
}
export
function
getActiveElement
(
node
:
HTMLElement
|
null
)
{
export
function
getActiveElement
(
node
:
HTMLElement
|
null
)
{
...
...
packages/next/src/next-devtools/dev-overlay/menu/dev-overlay-menu.tsx
View file @
684c7c01
import
{
useDevOverlayContext
}
from
'../../dev-overlay.browser'
import
{
useDevOverlayContext
}
from
'../../dev-overlay.browser'
import
{
useClickOutsideAndEscape
}
from
'../components/errors/dev-tools-indicator/utils'
import
{
useClickOutsideAndEscape
}
from
'../components/errors/dev-tools-indicator/utils'
import
{
import
{
experimental_useEffectEvent
as
useEffectEvent
,
useLayoutEffect
,
useLayoutEffect
,
useRef
,
useRef
,
createContext
,
createContext
,
...
@@ -134,14 +135,18 @@ export const DevtoolMenu = ({
...
@@ -134,14 +135,18 @@ export const DevtoolMenu = ({
}
}
}
}
)
)
useLayoutEffect
(()
=>
{
const
fireInitialSelectMenuItem
=
useEffectEvent
(()
=>
{
menuRef
.
current
?.
focus
()
// allows keydown to be captured
selectMenuItem
({
selectMenuItem
({
index
:
selectedIndex
===
-
1
?
'first'
:
selectedIndex
,
index
:
selectedIndex
===
-
1
?
'first'
:
selectedIndex
,
menuRef
,
menuRef
,
setSelectedIndex
,
setSelectedIndex
,
})
})
// eslint-disable-next-line react-hooks/exhaustive-deps
})
useLayoutEffect
(()
=>
{
menuRef
.
current
?.
focus
()
// allows keydown to be captured
// eslint-disable-next-line react-hooks/rules-of-hooks -- eprh bug
fireInitialSelectMenuItem
()
},
[])
},
[])
const
indicatorOffset
=
getIndicatorOffset
(
state
)
const
indicatorOffset
=
getIndicatorOffset
(
state
)
...
...
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