[DevTools] Render the highlight overlay in the top layer #37823

Open
UditDewan opened 12:07am on October 13, 2026 wants to merge 10 ฮ” into facebook/react main from
devtools-overlay-top-layer

Website or app

https://codesandbox.io/p/sandbox/ws7dp6

Repro steps

The Inspect button lets you lookup a component in the tree by clicking on it.

This is not working with top-layer elements, like <dialog> opened via showModal.

  1. Navigate to https://ws7dp6.csb.app/
  2. Open React Dev Tools > Components
  3. Click the Inspect button (there are two icons of a cursor inside a rectangle at the top left, the browser's built-in one works, the one in React Dev Tools does not)
  4. Click inside the dialog
  5. Notice that nothing is selected.

The issue is packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js:169 uses a really high z-index, instead of entering the top layer.

https://github.com/user-attachments/assets/3ea438f3-3362-4e37-9c81-8f9ffd0540b7

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)


Error component stack (automated)


GitHub query string (automated)


UditDewan authored
of work between October 12 and October 13
Diff Delta:
10
About 7 Diff Delta/hour
Classified as:  Bug Fix

UditDewan's Description of Work #37534 [DevTools Bug]: Inspect button does not work with top-layer elements like <dialog>

Summary

Fixes #37534.

The element highlight overlay (used by the Inspect button and when hovering the Components tree) sits above the page with z-index: 10000000. A z-index can't stack anything above top layer elements, so when a modal <dialog> (opened with showModal()) is on screen, the overlay draws underneath it. When you inspect something inside the dialog, you get no highlight.

This makes the overlay container a popover="manual" element and calls showPopover() after mounting it, so the overlay also renders in the top layer. The TraceUpdates canvas already does the same thing (#32614). The default popover UA styles (border, padding, background, margin, overflow) are reset so the container itself stays an invisible 0ร—0 box. pointer-events: none keeps it from intercepting clicks. Environments without the Popover API keep the existing z-index behavior.

How did you test this change?

I bundled the real Overlay.js (flow types stripped) into a page that opens a modal <dialog>, then used Playwright with Edge to compare screenshots of the dialog area before and after calling overlay.inspect() on an element inside the dialog:

overlay visible over the dialog
container in top layer (:popover-open)
container size

main
no
no
1280px wide (block div)

this PR
yes
yes
0ร—0



  • yarn prettier, yarn linc


  • flow check for dom-node: no errors

1 total changed file
Loading changes...
You've reached the end of this PR review
Thus concludes todayโ€™s episode of โ€œJust One Small Changeโ€