Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevTools] Highlight RN elements on hover #25106

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const SHOW_DURATION = 2000;
let timeoutID: TimeoutID | null = null;
let overlay: Overlay | null = null;

export function hideOverlay() {
export function hideOverlay(agent: Agent) {
if (window.document == null) {
agent.emit('hideNativeHighlight');
return;
}
timeoutID = null;

if (overlay !== null) {
Expand All @@ -33,6 +37,9 @@ export function showOverlay(
) {
// TODO (npm-packages) Detect RN and support it somehow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this TODO now? :)

if (window.document == null) {
if (elements != null && elements[0] != null) {
agent.emit('showNativeHighlight', elements[0]);
}
return;
}

Expand All @@ -51,6 +58,6 @@ export function showOverlay(
overlay.inspect(elements, componentName);

if (hideAfterTimeout) {
timeoutID = setTimeout(hideOverlay, SHOW_DURATION);
timeoutID = setTimeout(() => hideOverlay(agent), SHOW_DURATION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function setupHighlighter(
}

function stopInspectingNative() {
hideOverlay();
hideOverlay(agent);
removeListenersOnWindow(window);
iframesListeningTo.forEach(function(frame) {
try {
Expand All @@ -78,7 +78,7 @@ export default function setupHighlighter(
}

function clearNativeElementHighlight() {
hideOverlay();
hideOverlay(agent);
}

function highlightNativeElement({
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function setupHighlighter(
bridge.send('syncSelectionToNativeElementsPanel');
}
} else {
hideOverlay();
hideOverlay(agent);
}
}

Expand Down