Skip to content

[DevTools] Use Popover API for component inspect overlays #32703

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yongsk0066
Copy link
Contributor

Following the Popover API integration in #32614, this PR adds the same capability to Component Inspector highlighting in React DevTools.

Summary

When selecting a component in the Components tab, the highlighting overlays currently appear behind elements that use the browser's top-layer (such as elements or components using the Popover API). This makes it difficult to see component structure and dimensions when they are inside or behind top-layer elements.

This change modifies the Overlay.js module to use the Popover API, ensuring that component highlighting always appears above all other content, including elements in the browser's top-layer. The implementation centrally manages popover controls and follows the same pattern as the recently merged TraceUpdates PR for consistency.

How did you test this change?

I tested this change in the following ways:

  1. Manual testing with a test application that includes:
    • Components inside elements
    • Components inside elements using the Popover API
    • Selection of complex nested component hierarchies
  2. Verification steps:
    • Selected components in the Components tab with DevTools
    • Confirmed highlighting appears correctly on top of dialog and popover elements
    • Verified all highlighting elements (margins, borders, padding, content) display correctly
    • Ensured the tooltip with component name and dimensions appears properly
    • Checked that existing functionality and visual styling remains consistent

All functionality works as expected, with component highlighting now correctly appearing on top of all content, including top-layer elements.

demo-page
demo-repo

AS-IS

overlay_as_is.mov

TO-BE

overlay_to_be.mov

Comment on lines +274 to +286
this.rects.forEach(rect => {
if (!rect.node.matches(':popover-open')) {
// $FlowFixMe[prop-missing]: Flow doesn't recognize Popover API
// $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API
rect.node.showPopover();
}
});

if (!this.tip.tip.matches(':popover-open')) {
// $FlowFixMe[prop-missing]: Flow doesn't recognize Popover API
// $FlowFixMe[incompatible-use]: Flow doesn't recognize Popover API
this.tip.tip.showPopover();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought hidePopover was unnecessary in this case because the element is completely removed from the DOM during the remove phase.

@yongsk0066
Copy link
Contributor Author

Hi @hoxyq , I've also applied the Popover API changes to the component inspector overlays and created a separate PR for it.
Feel free to take a look when you have time. Thanks again!

Enhance the Components tab's element highlighting feature to use the Popover API for top layer rendering. This ensures highlight overlays always appear above other content including dialogs, tooltips, and other top layer elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants