浏览代码

fix search input blur

AykutSarac 2 年之前
父节点
当前提交
393cd7ec59
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      src/components/Graph/index.tsx

+ 6 - 0
src/components/Graph/index.tsx

@@ -79,6 +79,11 @@ const MemoizedGraph = React.memo(function Layout({
     }
   }, []);
 
+  const onCanvasClick = React.useCallback(() => {
+    const input = document.querySelector("input:focus") as HTMLInputElement;
+    if (input) input.blur();
+  }, []);
+
   React.useEffect(() => {
     const { nodes, edges } = parser(json, expand);
 
@@ -111,6 +116,7 @@ const MemoizedGraph = React.memo(function Layout({
             maxHeight={size.height}
             direction={layout}
             onLayoutChange={onLayoutChange}
+            onCanvasClick={onCanvasClick}
             key={layout}
             zoomable={false}
             animated={false}