@@ -129,7 +129,7 @@ const { expanded: expandedTreeNodes } = createExpandedContext()
129
129
const { expanded : expandedStateNodes } = createExpandedContext (' component-state' )
130
130
createSelectedContext ()
131
131
132
- function getComponentsInspectorTree(filter = ' ' ) {
132
+ async function getComponentsInspectorTree(filter = ' ' ) {
133
133
return rpc .value .getInspectorTree ({ inspectorId , filter }).then ((data ) => {
134
134
const res = parse (data )
135
135
tree .value = res
@@ -184,14 +184,32 @@ rpc.functions.on(DevToolsMessagingEvents.INSPECTOR_STATE_UPDATED, onInspectorSta
184
184
185
185
getComponentsInspectorTree ()
186
186
187
+ function searchComponentTree(v : string ) {
188
+ const value = v .trim ().toLowerCase ()
189
+ toggleFiltered ()
190
+ getComponentsInspectorTree (value ).then (() => {
191
+ toggleFiltered ()
192
+ })
193
+ }
194
+
195
+ watchDebounced (filterComponentName , (v ) => {
196
+ searchComponentTree (v )
197
+ }, { debounce: 300 })
198
+
187
199
function onInspectorTreeUpdated(_data : string ) {
188
200
const data = parse (_data ) as {
189
201
inspectorId: string
190
202
rootNodes: CustomInspectorNode []
191
203
}
192
204
if (data .inspectorId !== inspectorId )
193
205
return
194
- tree .value = data .rootNodes
206
+
207
+ if (filterComponentName .value ) {
208
+ searchComponentTree (filterComponentName .value )
209
+ }
210
+ else {
211
+ tree .value = data .rootNodes
212
+ }
195
213
196
214
if (! flattenedTreeNodesIds .value .includes (activeComponentId .value )) {
197
215
activeComponentId .value = tree .value ?.[0 ]?.id
@@ -206,14 +224,6 @@ onUnmounted(() => {
206
224
rpc .functions .off (DevToolsMessagingEvents .INSPECTOR_TREE_UPDATED , onInspectorTreeUpdated )
207
225
})
208
226
209
- watchDebounced (filterComponentName , (v ) => {
210
- const value = v .trim ().toLowerCase ()
211
- toggleFiltered ()
212
- getComponentsInspectorTree (value ).then (() => {
213
- toggleFiltered ()
214
- })
215
- }, { debounce: 300 })
216
-
217
227
function inspectComponentInspector() {
218
228
inspectComponentTipVisible .value = true
219
229
emit (' onInspectComponentStart' )
0 commit comments