Skip to content

fix(devtools): clear highlight when mouse leaves DevTools panel#36177

Open
petertdinh wants to merge 1 commit intofacebook:mainfrom
petertdinh:patch-1
Open

fix(devtools): clear highlight when mouse leaves DevTools panel#36177
petertdinh wants to merge 1 commit intofacebook:mainfrom
petertdinh:patch-1

Conversation

@petertdinh
Copy link
Copy Markdown

Fixes #17855

When hovering a component in the DevTools Components inspector, a highlight overlay appears on the inspected page. The highlight is cleared via onMouseLeave on the tree container div. But this React synthetic event only fires when the pointer transitions between elements within the same document. When the user moves their mouse out of the DevTools panel window entirely (e.g. to the browser viewport), no element in the React tree receives mouseleave, so clearHostInstanceHighlight is never sent over the bridge and the overlay persists on the page.

The fix adds a native mouseleave listener on the DevTools panel's ownerDocument in Tree.js. When the pointer exits the panel viewport, it fires clearHighlightHostInstance and removes the overlay. Using ownerDocument (rather than document) is consistent with the existing pattern in Tree.js for browser extension compatibility.

How did you test this change?

Tested manually using the Chrome extension:

  1. Opened React DevTools → Components tab on a React app
  2. Hovered a component in the tree — highlight appeared on the page ✓
  3. Moved the mouse out of the DevTools panel into the browser viewport — highlight cleared immediately ✓ (previously it persisted)
  4. Moved the mouse back into the panel and hovered a component — highlighting still works normally ✓
  5. Unhovered within the panel — highlight still clears correctly ✓

Ran the DevTools test suite: yarn test --no-watchman ReactDevTools — all tests pass.

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 1, 2026

Hi @petertdinh!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 1, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

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.

Bug: DevTools DOM highlighting gets stuck after a prolonged hover

1 participant