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;
1616let timeoutID : TimeoutID | null = null ;
1717let overlay : Overlay | null = null ;
1818
19- export function hideOverlay ( ) {
19+ export function hideOverlay ( agent : Agent ) {
20+ if ( window . document == null ) {
21+ agent . emit ( 'hideNativeHighlight' ) ;
22+ return ;
23+ }
2024 timeoutID = null ;
2125
2226 if ( overlay !== null ) {
@@ -31,8 +35,10 @@ export function showOverlay(
3135 agent : Agent ,
3236 hideAfterTimeout : boolean ,
3337) {
34- // TODO (npm-packages) Detect RN and support it somehow
3538 if ( window . document == null ) {
39+ if ( elements != null && elements [ 0 ] != null ) {
40+ agent . emit ( 'showNativeHighlight' , elements [ 0 ] ) ;
41+ }
3642 return ;
3743 }
3844
@@ -51,6 +57,6 @@ export function showOverlay(
5157 overlay . inspect ( elements , componentName ) ;
5258
5359 if ( hideAfterTimeout ) {
54- timeoutID = setTimeout ( hideOverlay , SHOW_DURATION ) ;
60+ timeoutID = setTimeout ( ( ) => hideOverlay ( agent ) , SHOW_DURATION ) ;
5561 }
5662}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export default function setupHighlighter(
5454 }
5555
5656 function stopInspectingNative ( ) {
57- hideOverlay ( ) ;
57+ hideOverlay ( agent ) ;
5858 removeListenersOnWindow ( window ) ;
5959 iframesListeningTo . forEach ( function ( frame ) {
6060 try {
@@ -82,7 +82,7 @@ export default function setupHighlighter(
8282 }
8383
8484 function clearNativeElementHighlight ( ) {
85- hideOverlay ( ) ;
85+ hideOverlay ( agent ) ;
8686 }
8787
8888 function highlightNativeElement ( {
@@ -129,7 +129,7 @@ export default function setupHighlighter(
129129 bridge . send ( 'syncSelectionToNativeElementsPanel' ) ;
130130 }
131131 } else {
132- hideOverlay ( ) ;
132+ hideOverlay ( agent ) ;
133133 }
134134 }
135135
You can’t perform that action at this time.
0 commit comments