Skip to content

[DevTools] Clear element inspection if host element not owned by any renderer is selected#333

Closed
everettbu wants to merge 3 commits into
mainfrom
sebbie/01-13-_devtools_clear_element_inspection_if_host_element_not_owned_by_any_renderer_is_selected
Closed

[DevTools] Clear element inspection if host element not owned by any renderer is selected#333
everettbu wants to merge 3 commits into
mainfrom
sebbie/01-13-_devtools_clear_element_inspection_if_host_element_not_owned_by_any_renderer_is_selected

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35504
Original author: eps1lon


Stacked on react/react#35503

If you click outside a React root in the Elements panel, we want to give eedback that no selection is possible so we clear the selection. Otherwise clicking outside a React root is indistinguishable from clicking a different host node that leads to the same selected React element due to Component filters.

Test plan

  1. Open a document where not all DOM nodes are rendered by React e.g. https://react.new/
  2. Select a DOM node owned by React
  3. Select a DOM node not owned by React
CleanShot.2026-01-13.at.19.22.50.mp4
  1. Open a document where not all DOM nodes are rendered by React e.g. https://react.new/
  2. Open Components panel
  3. inspect element
  4. Open Elements panel (should clear inspection since the selected host node is not owned by React)
CleanShot.2026-01-13.at.20.02.00.mp4

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Jan 13, 2026
@greptile-apps

greptile-apps Bot commented Jan 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR improves the DevTools' element inspection behavior by enabling clear visual feedback when selecting non-React elements. The core change allows the extension to send null through the selection pipeline when users click on DOM nodes not owned by React, which clears the Components panel selection and distinguishes this state from selecting different React elements.

Key Changes:

  • Backend now sends null to the bridge when selectNode() is called with a non-React element
  • Store properly handles null selections and emits events to update UI state
  • Frontend receives null selections and clears inspection in the Components panel
  • Type system updated across bridge, store, and components to support nullable element IDs
  • Extension syncs selection when Elements panel is opened via new syncSelectionFromBuiltinElementsPanel message
  • Removed unused editor pane visibility event emitters that had no listeners

The implementation maintains backward compatibility while adding the new null-selection behavior. All event handlers and reducers properly support the null case.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues. Type system changes are consistent across all modules, logic for null selection handling is correct, and removed code had no active consumers.
  • All changes follow a coherent pattern: extending type definitions to support null, updating event handlers to accept and propagate null values, and ensuring the UI state resets when non-React elements are selected. The early-return logic in store.js correctly forces event emission when elementId is null, preventing false deduplication. Removal of unused event emitters is safe as no other code depends on them. The extension's new syncSelection call properly triggers state synchronization. No logical errors, type mismatches, or security concerns were identified."
  • No files require special attention

@everettbu
everettbu force-pushed the sebbie/01-13-_devtools_clear_element_inspection_if_host_element_not_owned_by_any_renderer_is_selected branch from 48bb909 to a02311d Compare January 15, 2026 13:23
@everettbu
everettbu force-pushed the sebbie/01-13-_devtools_clear_element_inspection_if_host_element_not_owned_by_any_renderer_is_selected branch from a02311d to fb80c19 Compare January 16, 2026 12:13
@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Jan 16, 2026
@everettbu
everettbu deleted the sebbie/01-13-_devtools_clear_element_inspection_if_host_element_not_owned_by_any_renderer_is_selected branch January 16, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants