File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
packages/next/src/next-devtools/dev-overlay Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({
3737 )
3838
3939 useOnClickOutside (
40- // eslint-disable-next-line react-hooks/react-compiler -- TODO
41- dialogRef . current ,
40+ dialogRef ,
4241 CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE ,
4342 ( e ) => {
4443 e . preventDefault ( )
Original file line number Diff line number Diff line change 11import * as React from 'react'
22
33export function useOnClickOutside (
4- el : Node | null ,
4+ el : Node | React . RefObject < Node | null > | null ,
55 cssSelectorsToExclude : string [ ] ,
66 handler : ( ( e : MouseEvent | TouchEvent ) => void ) | undefined
77) {
88 React . useEffect ( ( ) => {
9- if ( el == null || handler == null ) {
9+ // Support both direct nodes and ref objects
10+ const element = el && 'current' in el ? el . current : el
11+ if ( element == null || handler == null ) {
1012 return
1113 }
1214
1315 const listener = ( e : MouseEvent | TouchEvent ) => {
1416 // Do nothing if clicking ref's element or descendent elements
15- if ( ! el || el . contains ( e . target as Element ) ) {
17+ if ( ! element || element . contains ( e . target as Element ) ) {
1618 return
1719 }
1820
@@ -28,7 +30,7 @@ export function useOnClickOutside(
2830 handler ( e )
2931 }
3032
31- const root = el . getRootNode ( )
33+ const root = element . getRootNode ( )
3234 root . addEventListener ( 'mouseup' , listener as EventListener )
3335 root . addEventListener ( 'touchend' , listener as EventListener , {
3436 passive : false ,
You can’t perform that action at this time.
0 commit comments