@@ -129,7 +129,7 @@ const { expanded: expandedTreeNodes } = createExpandedContext()
129129const { expanded : expandedStateNodes } = createExpandedContext (' component-state' )
130130createSelectedContext ()
131131
132- function getComponentsInspectorTree(filter = ' ' ) {
132+ async function getComponentsInspectorTree(filter = ' ' ) {
133133 return rpc .value .getInspectorTree ({ inspectorId , filter }).then ((data ) => {
134134 const res = parse (data )
135135 tree .value = res
@@ -184,14 +184,32 @@ rpc.functions.on(DevToolsMessagingEvents.INSPECTOR_STATE_UPDATED, onInspectorSta
184184
185185getComponentsInspectorTree ()
186186
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+
187199function onInspectorTreeUpdated(_data : string ) {
188200 const data = parse (_data ) as {
189201 inspectorId: string
190202 rootNodes: CustomInspectorNode []
191203 }
192204 if (data .inspectorId !== inspectorId )
193205 return
194- tree .value = data .rootNodes
206+
207+ if (filterComponentName .value ) {
208+ searchComponentTree (filterComponentName .value )
209+ }
210+ else {
211+ tree .value = data .rootNodes
212+ }
195213
196214 if (! flattenedTreeNodesIds .value .includes (activeComponentId .value )) {
197215 activeComponentId .value = tree .value ?.[0 ]?.id
@@ -206,14 +224,6 @@ onUnmounted(() => {
206224 rpc .functions .off (DevToolsMessagingEvents .INSPECTOR_TREE_UPDATED , onInspectorTreeUpdated )
207225})
208226
209- watchDebounced (filterComponentName , (v ) => {
210- const value = v .trim ().toLowerCase ()
211- toggleFiltered ()
212- getComponentsInspectorTree (value ).then (() => {
213- toggleFiltered ()
214- })
215- }, { debounce: 300 })
216-
217227function inspectComponentInspector() {
218228 inspectComponentTipVisible .value = true
219229 emit (' onInspectComponentStart' )
0 commit comments