diff --git a/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx b/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx index 55faf5b1f75..05018fbeeed 100644 --- a/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx +++ b/packages/grafana-ui/src/components/VizLayout/VizLayout.tsx @@ -61,7 +61,7 @@ export const VizLayout: VizLayoutComponentType = ({ width, height, legend, child containerStyle.flexDirection = 'column'; legendStyle.maxHeight = maxHeight; - if (legendMeasure) { + if (legendMeasure.height) { size = { width, height: height - legendMeasure.height }; } break; @@ -69,7 +69,7 @@ export const VizLayout: VizLayoutComponentType = ({ width, height, legend, child containerStyle.flexDirection = 'row'; legendStyle.maxWidth = maxWidth; - if (legendMeasure) { + if (legendMeasure.width) { size = { width: width - legendMeasure.width, height }; } diff --git a/public/app/plugins/panel/piechart/PieChartPanel.test.tsx b/public/app/plugins/panel/piechart/PieChartPanel.test.tsx index 0b315565a5b..3d1f2536f11 100644 --- a/public/app/plugins/panel/piechart/PieChartPanel.test.tsx +++ b/public/app/plugins/panel/piechart/PieChartPanel.test.tsx @@ -16,6 +16,11 @@ import { LegendDisplayMode, SortOrder, TooltipDisplayMode } from '@grafana/schem import { PieChartPanel } from './PieChartPanel'; import { PanelOptions, PieChartType, PieChartLegendValues } from './panelcfg.gen'; +jest.mock('react-use', () => ({ + ...jest.requireActual('react-use'), + useMeasure: () => [() => {}, { width: 100, height: 100 }], +})); + type PieChartPanelProps = ComponentProps; describe('PieChartPanel', () => {