Browse Source

fix search input blur

AykutSarac 2 năm trước cách đây
mục cha
commit
393cd7ec59
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  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(() => {
   React.useEffect(() => {
     const { nodes, edges } = parser(json, expand);
     const { nodes, edges } = parser(json, expand);
 
 
@@ -111,6 +116,7 @@ const MemoizedGraph = React.memo(function Layout({
             maxHeight={size.height}
             maxHeight={size.height}
             direction={layout}
             direction={layout}
             onLayoutChange={onLayoutChange}
             onLayoutChange={onLayoutChange}
+            onCanvasClick={onCanvasClick}
             key={layout}
             key={layout}
             zoomable={false}
             zoomable={false}
             animated={false}
             animated={false}