File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed 
EssentialCSharp.Web/wwwroot/js Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 66    markRaw , 
77    watch , 
88    computed , 
9+     watchEffect 
910}  from  "vue" ; 
1011import  {  useWindowSize  }  from  "vue-window-size" ; 
1112
@@ -238,8 +239,8 @@ const app = createApp({
238239        const  searchQuery  =  ref ( '' ) ; 
239240
240241        const  filteredTocData  =  computed ( ( )  =>  { 
241-             expandedTocs . clear ( ) ; 
242242            if  ( ! searchQuery . value )  { 
243+                 expandedTocs . clear ( ) ; 
243244                return  tocData ; 
244245            } 
245246            const  query  =  normalizeString ( searchQuery . value ) ; 
@@ -252,12 +253,20 @@ const app = createApp({
252253                const  childMatches  =  item . items . some ( child  =>  filterItem ( child ,  query ) ) ; 
253254                matches  =  matches  ||  childMatches ; 
254255            } 
255-             if  ( matches )  { 
256-                 expandedTocs . add ( item . key ) ;  // Add matching item to expandedTocs 
257-             } 
258256            return  matches ; 
259257        } 
260258
259+         watchEffect ( ( )  =>  { 
260+             expandedTocs . clear ( ) ; 
261+             const  query  =  normalizeString ( searchQuery . value ) ; 
262+             tocData . forEach ( item  =>  { 
263+                 if  ( filterItem ( item ,  query ) )  { 
264+                     expandedTocs . add ( item . key ) ; 
265+                     console . log ( "Added " ,  item . key ) ; 
266+                 } 
267+             } ) ; 
268+         } ) ; 
269+ 
261270        function  normalizeString ( str )  { 
262271            return  str . replace ( / [ ^ \w \s ] | _ / g,  "" ) . replace ( / \s + / g,  " " ) . toLowerCase ( ) ; 
263272        } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments