Skip to content

Commit

Permalink
Fixed fit-height for react 18
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot committed Jul 26, 2023
1 parent 67ea10c commit 55899f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/area-chart/model/use-chart-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default function useChartModel<T extends AreaChartProps.DataTypes>({

const plotMeasureRef = useRef<SVGLineElement>(null);
const hasVisibleSeries = series.length > 0;
const height = useHeightMeasure(() => plotMeasureRef.current, !fitHeight, [hasVisibleSeries]) ?? explicitHeight;
const height =
useHeightMeasure(() => plotMeasureRef.current, !fitHeight, [hasVisibleSeries, fitHeight]) ?? explicitHeight;

const stableSetVisibleSeries = useStableEventHandler(setVisibleSeries);

Expand Down
5 changes: 4 additions & 1 deletion src/mixed-line-bar-chart/chart-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export default function ChartContainer<T extends ChartDataTypes>({
const popoverRef = useRef<HTMLElement | null>(null);

const plotMeasureRef = useRef<SVGLineElement>(null);
const measuredHeight = useHeightMeasure(() => plotMeasureRef.current, !fitHeight || !bottomLabelsHeight);
const measuredHeight = useHeightMeasure(() => plotMeasureRef.current, !fitHeight || !bottomLabelsHeight, [
fitHeight,
bottomLabelsHeight,
]);
const plotHeight = fitHeight ? (bottomLabelsHeight ? measuredHeight ?? 0 : 0) : explicitPlotHeight;

const isRefresh = useVisualRefresh();
Expand Down
2 changes: 1 addition & 1 deletion src/pie-chart/pie-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default <T extends PieChartProps.Datum>({
const hasLabels = !(hideTitles && hideDescriptions);
const isRefresh = useVisualRefresh();

const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight) ?? explicitHeight;
const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight, [fitHeight]) ?? explicitHeight;

const dimensions = useMemo(
() =>
Expand Down

0 comments on commit 55899f7

Please sign in to comment.