mirror of
				https://github.com/HKUDS/LightRAG.git
				synced 2025-11-04 03:39:35 +00:00 
			
		
		
		
	Improve graph label search functionality and UI behavior
- Display a drop down list box when user input is empty - Ensure graph is available before searching
This commit is contained in:
		
							parent
							
								
									dc74c889b0
								
							
						
					
					
						commit
						06bff7e836
					
				@ -85,7 +85,18 @@ export const GraphSearchInput = ({
 | 
			
		||||
  const loadOptions = useCallback(
 | 
			
		||||
    async (query?: string): Promise<OptionItem[]> => {
 | 
			
		||||
      if (onFocus) onFocus(null)
 | 
			
		||||
      if (!query || !searchEngine) return []
 | 
			
		||||
      if (!graph || !searchEngine) return []
 | 
			
		||||
 | 
			
		||||
      // If no query, return first searchResultLimit nodes
 | 
			
		||||
      if (!query) {
 | 
			
		||||
        const nodeIds = graph.nodes().slice(0, searchResultLimit)
 | 
			
		||||
        return nodeIds.map(id => ({
 | 
			
		||||
          id,
 | 
			
		||||
          type: 'nodes'
 | 
			
		||||
        }))
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // If has query, search nodes
 | 
			
		||||
      const result: OptionItem[] = searchEngine.search(query).map((r: { id: string }) => ({
 | 
			
		||||
        id: r.id,
 | 
			
		||||
        type: 'nodes'
 | 
			
		||||
@ -103,7 +114,7 @@ export const GraphSearchInput = ({
 | 
			
		||||
          }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    [searchEngine, onFocus, t]
 | 
			
		||||
    [graph, searchEngine, onFocus, t]
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
 | 
			
		||||
@ -193,7 +193,7 @@ export function AsyncSearch<T>({
 | 
			
		||||
            </div>
 | 
			
		||||
          )}
 | 
			
		||||
        </div>
 | 
			
		||||
        <CommandList hidden={!open || debouncedSearchTerm.length === 0}>
 | 
			
		||||
        <CommandList hidden={!open}>
 | 
			
		||||
          {error && <div className="text-destructive p-4 text-center">{error}</div>}
 | 
			
		||||
          {loading && options.length === 0 && (loadingSkeleton || <DefaultLoadingSkeleton />)}
 | 
			
		||||
          {!loading &&
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user