diff --git a/lightrag_webui/src/components/graph/ZoomControl.tsx b/lightrag_webui/src/components/graph/ZoomControl.tsx index 5739ea67..b978c3b0 100644 --- a/lightrag_webui/src/components/graph/ZoomControl.tsx +++ b/lightrag_webui/src/components/graph/ZoomControl.tsx @@ -27,7 +27,8 @@ const ZoomControl = () => { const graph = sigma.getGraph() // Check if graph has nodes before accessing them - if (!graph || graph.nodes().length === 0) { + if (!graph?.order || graph.nodes().length === 0) { + // Use reset() for empty graph case reset() return } @@ -73,6 +74,8 @@ const ZoomControl = () => { ) } catch (error) { console.error('Error resetting zoom:', error) + // Use reset() as fallback on error + reset() } }, [sigma, reset])