@@ -124,7 +124,6 @@ export default class Agent extends EventEmitter<{|
124124 bridge . addListener ( 'overrideState' , this . overrideState ) ;
125125 bridge . addListener ( 'overrideSuspense' , this . overrideSuspense ) ;
126126 bridge . addListener ( 'reloadAndProfile' , this . reloadAndProfile ) ;
127- bridge . addListener ( 'selectElement' , this . selectElement ) ;
128127 bridge . addListener ( 'startProfiling' , this . startProfiling ) ;
129128 bridge . addListener ( 'stopProfiling' , this . stopProfiling ) ;
130129 bridge . addListener (
@@ -219,6 +218,24 @@ export default class Agent extends EventEmitter<{|
219218 console . warn ( `Invalid renderer id "${ rendererID } " for element "${ id } "` ) ;
220219 } else {
221220 this . _bridge . send ( 'inspectedElement' , renderer . inspectElement ( id , path ) ) ;
221+
222+ // When user selects an element, stop trying to restore the selection,
223+ // and instead remember the current selection for the next reload.
224+ if (
225+ this . _persistedSelectionMatch === null ||
226+ this . _persistedSelectionMatch . id !== id
227+ ) {
228+ this . _persistedSelection = null ;
229+ this . _persistedSelectionMatch = null ;
230+ renderer . setTrackedPath ( null ) ;
231+ this . _throttledPersistSelection ( rendererID , id ) ;
232+ }
233+
234+ // TODO: If there was a way to change the selected DOM element
235+ // in native Elements tab without forcing a switch to it, we'd do it here.
236+ // For now, it doesn't seem like there is a way to do that:
237+ // https://github.com/bvaughn/react-devtools-experimental/issues/102
238+ // (Setting $0 doesn't work, and calling inspect() switches the tab.)
222239 }
223240 } ;
224241
@@ -244,33 +261,6 @@ export default class Agent extends EventEmitter<{|
244261 this . _bridge . send ( 'reloadAppForProfiling' ) ;
245262 } ;
246263
247- selectElement = ( { id, rendererID } : ElementAndRendererID ) => {
248- const renderer = this . _rendererInterfaces [ rendererID ] ;
249- if ( renderer == null ) {
250- console . warn ( `Invalid renderer id "${ rendererID } " for element "${ id } "` ) ;
251- } else {
252- renderer . selectElement ( id ) ;
253-
254- // When user selects an element, stop trying to restore the selection,
255- // and instead remember the current selection for the next reload.
256- if (
257- this . _persistedSelectionMatch === null ||
258- this . _persistedSelectionMatch . id !== id
259- ) {
260- this . _persistedSelection = null ;
261- this . _persistedSelectionMatch = null ;
262- renderer . setTrackedPath ( null ) ;
263- this . _throttledPersistSelection ( rendererID , id ) ;
264- }
265-
266- // TODO: If there was a way to change the selected DOM element
267- // in native Elements tab without forcing a switch to it, we'd do it here.
268- // For now, it doesn't seem like there is a way to do that:
269- // https://github.com/bvaughn/react-devtools-experimental/issues/102
270- // (Setting $0 doesn't work, and calling inspect() switches the tab.)
271- }
272- } ;
273-
274264 overrideContext = ( { id, path, rendererID, value } : SetInParams ) => {
275265 const renderer = this . _rendererInterfaces [ rendererID ] ;
276266 if ( renderer == null ) {
0 commit comments