File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,14 @@ export function useClickOutside(
91
91
return
92
92
}
93
93
94
+ const ownerDocument = rootRef . current ?. ownerDocument
95
+
94
96
function handleClickOutside ( event : MouseEvent ) {
97
+ const target = event . target as HTMLElement
98
+ if ( rootRef . current && rootRef . current . contains ( target ) ) {
99
+ return
100
+ }
101
+
95
102
if (
96
103
! ( rootRef . current ?. getBoundingClientRect ( )
97
104
? event . clientX >= rootRef . current . getBoundingClientRect ( ) ! . left &&
@@ -117,12 +124,12 @@ export function useClickOutside(
117
124
}
118
125
}
119
126
120
- document . addEventListener ( 'mousedown' , handleClickOutside )
121
- document . addEventListener ( 'keydown' , handleKeyDown )
127
+ ownerDocument ? .addEventListener ( 'mousedown' , handleClickOutside )
128
+ ownerDocument ? .addEventListener ( 'keydown' , handleKeyDown )
122
129
123
130
return ( ) => {
124
- document . removeEventListener ( 'mousedown' , handleClickOutside )
125
- document . removeEventListener ( 'keydown' , handleKeyDown )
131
+ ownerDocument ? .removeEventListener ( 'mousedown' , handleClickOutside )
132
+ ownerDocument ? .removeEventListener ( 'keydown' , handleKeyDown )
126
133
}
127
134
// eslint-disable-next-line react-hooks/exhaustive-deps
128
135
} , [ active ] )
You can’t perform that action at this time.
0 commit comments