Skip to content

Conversation

@eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Nov 27, 2025

Closes #32574

Adds a dedicated pane for inspecting the React Element that rendered the inspected DOM element.
The main motivation is having an affordance to open the source where the DOM element is rendered.

CleanShot.2025-11-28.at.00.25.16.mp4

The new pane has three UX quirks:

  1. selecting a DOM element with no matching React element does not change the inspected React Element
    I feel like this should trigger de-selection instead
    [DevTools] Clear element inspection if host element not owned by any renderer is selected #35504
  2. There's no fallback
    So far no fallback was good enough for the Components and Suspense tab because you couldn't escape React Elements in those tabs. In the browsers Elements panel it's much easier to do so a fallback is warranted. Probably fine to add the fallback in every context.
    [DevTools] Show fallback in inspected element pane when no element is selected #35503
  3. If you're filtering DOM elements (default), you might be confused ho clicking a DOM element does not inspect the React element but a parent. That's especially confusing when you click different DOM elements with the same parent and the inspected element doesn't change.
    I don't have a solution for that yet. Maybe that's fine in the end and it's something you get used to. The main problem right now is that initial load ignores the users setting and hides host Elements by default. Fixing that particular bug might help this issue the most.

I'll work on 1 and 2 in follow-ups that should be handled before the next release. For 3, I want to investigate why the initial load always uses the default filter and if we can fix that.

Other follow-ups before release:

  1. We should be updating the inspected element when the filter changes while in the React Element pane. Right now you have to click back and forth to inspect the element according to the new filter.

@meta-cla meta-cla bot added the CLA Signed label Nov 27, 2025
@eps1lon eps1lon force-pushed the sebbie/11-28-_devtools_add_react_element_pane_to_browser_elements_panel branch from 29c965a to c63fec5 Compare November 27, 2025 23:32
@eps1lon eps1lon force-pushed the sebbie/11-28-_devtools_add_react_element_pane_to_browser_elements_panel branch 2 times, most recently from eb49d8f to 98337e1 Compare January 13, 2026 11:20
@eps1lon eps1lon marked this pull request as ready for review January 13, 2026 14:11
@eps1lon eps1lon requested review from hoxyq and sebmarkbage January 13, 2026 14:12
@eps1lon eps1lon force-pushed the sebbie/11-28-_devtools_add_react_element_pane_to_browser_elements_panel branch from 98337e1 to 3bcc570 Compare January 13, 2026 17:28

const elementsPanel = chrome.devtools.panels.elements;
if (!elementsPanel || !elementsPanel.createSidebarPane) {
// TODO: Does Firefox support elements panel extensions?
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

C&P from the added sources pane which isn't supported in Firefox. The right compat table is https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools/panels/ElementsPanel/createSidebarPane. So we should still leave the check in case we ever distribute this for Safari.

Copy link
Collaborator Author

@eps1lon eps1lon Jan 15, 2026

Choose a reason for hiding this comment

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

Thanks for the reminder. It actually doesn't work in Firefox due to https://bugzilla.mozilla.org/show_bug.cgi?id=2010549

inspectedElementPane = createdPane;

createdPane.setPage('panel.html');
createdPane.setHeight('75px');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it used as a min-height or how does this work? Might be worth double-checking the case when an element has a long list of props or hooks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was copied from the added sources pane. Though it's not supported in Firefox: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools/panels/ExtensionSidebarPane#browser_compatibility

I follow-up on this since whatever change we make, should affect all ExtensionSidebarPane.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually will do this now since I can't test Firefox otherwise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do in a follow-up since Firefox support is blocked by https://bugzilla.mozilla.org/show_bug.cgi?id=2010549

@eps1lon eps1lon merged commit fae15df into facebook:main Jan 15, 2026
233 of 234 checks passed
@eps1lon eps1lon deleted the sebbie/11-28-_devtools_add_react_element_pane_to_browser_elements_panel branch January 15, 2026 12:24
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.

[React 19] Need Bring Back _debugSource or Provide an Equivalent for Better Developer Experience

2 participants