File tree Expand file tree Collapse file tree 4 files changed +14
-8
lines changed
react-devtools-extensions/src/main
react-devtools-shared/src Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,7 @@ function createElementsInspectPanel() {
330330 inspectedElementPortalContainer = portal . container ;
331331 if ( inspectedElementPortalContainer != null && render ) {
332332 ensureInitialHTMLIsCleared ( inspectedElementPortalContainer ) ;
333+ bridge . send ( 'syncSelectionFromBuiltinElementsPanel' ) ;
333334
334335 render ( ) ;
335336 portal . injectStyles ( cloneStyleTags ) ;
Original file line number Diff line number Diff line change @@ -938,8 +938,8 @@ export default class Agent extends EventEmitter<{
938938 }
939939 } ;
940940
941- selectNode ( target : HostInstance ) : void {
942- const match = this . getIDForHostInstance ( target ) ;
941+ selectNode ( target : HostInstance | null ) : void {
942+ const match = target !== null ? this . getIDForHostInstance ( target ) : null ;
943943 this . _bridge . send (
944944 'selectElement' ,
945945 match !== null
@@ -996,10 +996,7 @@ export default class Agent extends EventEmitter<{
996996
997997 syncSelectionFromBuiltinElementsPanel : ( ) = > void = ( ) => {
998998 const target = window . __REACT_DEVTOOLS_GLOBAL_HOOK__ . $0 ;
999- if ( target == null ) {
1000- return ;
1001- }
1002- this . selectNode ( target ) ;
999+ this . selectNode ( target == null ? null : target ) ;
10031000 } ;
10041001
10051002 shutdown : ( ) = > void = ( ) => {
Original file line number Diff line number Diff line change @@ -2382,7 +2382,14 @@ export default class Store extends EventEmitter<{
23822382 } ;
23832383
23842384 onHostInstanceSelected: ( elementId : number | null ) => void = elementId => {
2385- if ( this . _lastSelectedHostInstanceElementId === elementId ) {
2385+ if (
2386+ this . _lastSelectedHostInstanceElementId === elementId &&
2387+ // Force clear selection e.g. when we inspect an element in the Components panel
2388+ // and then switch to the browser's Elements panel.
2389+ // We wouldn't want to stay on the inspected element if we're inspecting
2390+ // an element not owned by React when switching to the browser's Elements panel.
2391+ elementId !== null
2392+ ) {
23862393 return ;
23872394 }
23882395
Original file line number Diff line number Diff line change @@ -967,8 +967,9 @@ function TreeContextController({
967967
968968 // Listen for host element selections.
969969 useEffect ( ( ) => {
970- const handler = ( id : Element [ 'id' ] | null ) =>
970+ const handler = ( id : Element [ 'id' ] | null ) => {
971971 transitionDispatch ( { type : 'SELECT_ELEMENT_BY_ID' , payload : id } ) ;
972+ } ;
972973
973974 store . addListener ( 'hostInstanceSelected' , handler ) ;
974975 return ( ) => store . removeListener ( 'hostInstanceSelected' , handler ) ;
You can’t perform that action at this time.
0 commit comments