Jelajahi Sumber

fix: Calculation issue with AutoSizer in explore

Johannes Schill 6 tahun lalu
induk
melakukan
d68df9d704
1 mengubah file dengan 15 tambahan dan 13 penghapusan
  1. 15 13
      public/app/features/explore/Graph.tsx

+ 15 - 13
public/app/features/explore/Graph.tsx

@@ -265,17 +265,19 @@ export class Graph extends PureComponent<SizedGraphProps, GraphState> {
 }
 
 export default (props: GraphProps) => (
-  <AutoSizer>
-    {({width, height}) => {
-      return (
-        <Graph
-          size={{
-            width: width,
-            height: height
-          }}
-          {...props}
-        />
-      );
-    }}
-  </AutoSizer>
+  <div>{/* div needed for AutoSizer to calculate, https://github.com/bvaughn/react-virtualized/blob/master/docs/usingAutoSizer.md#observation */}
+    <AutoSizer disableHeight>
+      {({width, height}) => (
+        <div style={{width}}>
+          {width > 0 && <Graph
+            size={{
+              width: width,
+              height: height
+            }}
+            {...props}
+          />}
+        </div>
+      )}
+    </AutoSizer>
+  </div>
 );