VizLegend: Fixes flicking visualization height & re-render (#66331)

* VizLegend: Fixes flicking visualization height & re-render

* Fix test
This commit is contained in:
Torkel Ödegaard 2023-04-12 18:57:42 +02:00 committed by GitHub
parent 77852d587d
commit 0c032460ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -61,7 +61,7 @@ export const VizLayout: VizLayoutComponentType = ({ width, height, legend, child
containerStyle.flexDirection = 'column'; containerStyle.flexDirection = 'column';
legendStyle.maxHeight = maxHeight; legendStyle.maxHeight = maxHeight;
if (legendMeasure) { if (legendMeasure.height) {
size = { width, height: height - legendMeasure.height }; size = { width, height: height - legendMeasure.height };
} }
break; break;
@ -69,7 +69,7 @@ export const VizLayout: VizLayoutComponentType = ({ width, height, legend, child
containerStyle.flexDirection = 'row'; containerStyle.flexDirection = 'row';
legendStyle.maxWidth = maxWidth; legendStyle.maxWidth = maxWidth;
if (legendMeasure) { if (legendMeasure.width) {
size = { width: width - legendMeasure.width, height }; size = { width: width - legendMeasure.width, height };
} }

View File

@ -16,6 +16,11 @@ import { LegendDisplayMode, SortOrder, TooltipDisplayMode } from '@grafana/schem
import { PieChartPanel } from './PieChartPanel'; import { PieChartPanel } from './PieChartPanel';
import { PanelOptions, PieChartType, PieChartLegendValues } from './panelcfg.gen'; import { PanelOptions, PieChartType, PieChartLegendValues } from './panelcfg.gen';
jest.mock('react-use', () => ({
...jest.requireActual('react-use'),
useMeasure: () => [() => {}, { width: 100, height: 100 }],
}));
type PieChartPanelProps = ComponentProps<typeof PieChartPanel>; type PieChartPanelProps = ComponentProps<typeof PieChartPanel>;
describe('PieChartPanel', () => { describe('PieChartPanel', () => {