File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
packages/react-devtools-shared/src/backend/views/Highlighter Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,11 @@ const SHOW_DURATION = 2000;
16
16
let timeoutID : TimeoutID | null = null ;
17
17
let overlay : Overlay | null = null ;
18
18
19
- export function hideOverlay ( ) {
19
+ export function hideOverlay ( agent : Agent ) {
20
+ if ( window . document == null ) {
21
+ agent . emit ( 'hideNativeHighlight' ) ;
22
+ return ;
23
+ }
20
24
timeoutID = null ;
21
25
22
26
if ( overlay !== null ) {
@@ -31,8 +35,10 @@ export function showOverlay(
31
35
agent : Agent ,
32
36
hideAfterTimeout : boolean ,
33
37
) {
34
- // TODO (npm-packages) Detect RN and support it somehow
35
38
if ( window . document == null ) {
39
+ if ( elements != null && elements [ 0 ] != null ) {
40
+ agent . emit ( 'showNativeHighlight' , elements [ 0 ] ) ;
41
+ }
36
42
return ;
37
43
}
38
44
@@ -51,6 +57,6 @@ export function showOverlay(
51
57
overlay . inspect ( elements , componentName ) ;
52
58
53
59
if ( hideAfterTimeout ) {
54
- timeoutID = setTimeout ( hideOverlay , SHOW_DURATION ) ;
60
+ timeoutID = setTimeout ( ( ) => hideOverlay ( agent ) , SHOW_DURATION ) ;
55
61
}
56
62
}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export default function setupHighlighter(
54
54
}
55
55
56
56
function stopInspectingNative ( ) {
57
- hideOverlay ( ) ;
57
+ hideOverlay ( agent ) ;
58
58
removeListenersOnWindow ( window ) ;
59
59
iframesListeningTo . forEach ( function ( frame ) {
60
60
try {
@@ -82,7 +82,7 @@ export default function setupHighlighter(
82
82
}
83
83
84
84
function clearNativeElementHighlight ( ) {
85
- hideOverlay ( ) ;
85
+ hideOverlay ( agent ) ;
86
86
}
87
87
88
88
function highlightNativeElement ( {
@@ -129,7 +129,7 @@ export default function setupHighlighter(
129
129
bridge . send ( 'syncSelectionToNativeElementsPanel' ) ;
130
130
}
131
131
} else {
132
- hideOverlay ( ) ;
132
+ hideOverlay ( agent ) ;
133
133
}
134
134
}
135
135
You can’t perform that action at this time.
0 commit comments