Skip to content

Commit bee1fca

Browse files
jhfclaude
andcommitted
fix: Use dynamic import for Highcharts accessibility module in history reports
Static import caused TypeError: Cannot read properties of undefined (reading 'Templating') because the accessibility module's UMD wrapper expects Highcharts core to be initialized first. Dynamic import inside useGuardedEffect matches the pattern already used in ReportsPageClient. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 436040e commit bee1fca

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/app/reports/history-reports.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { useCallback, useMemo, useState, type ReactNode } from "react";
4-
import "highcharts/modules/accessibility";
4+
import { useGuardedEffect } from "@/hooks/use-guarded-effect";
55

66
import { useStatisticalHistoryHighcharts } from "./history-changes/use-statistical-history-highcharts";
77
import { Skeleton } from "@/components/ui/skeleton";
@@ -52,6 +52,14 @@ export function HistoryReports({
5252
return Array.from(new Set(years)).sort((a, b) => b - a);
5353
}, [timeContexts]);
5454

55+
const [highchartsModulesLoaded, setHighchartsModulesLoaded] = useState(false);
56+
57+
useGuardedEffect(() => {
58+
import("highcharts/modules/accessibility").then(() => {
59+
setHighchartsModulesLoaded(true);
60+
});
61+
}, [], 'HistoryReports:importHighchartsModules');
62+
5563
const { history, isLoading } = useStatisticalHistoryHighcharts(
5664
resolution,
5765
selectedUnitType,
@@ -93,7 +101,7 @@ export function HistoryReports({
93101

94102
</div>
95103
</div>
96-
{!isLoading && history ? (
104+
{!isLoading && history && highchartsModulesLoaded ? (
97105
children({
98106
history,
99107
isYearlyView: selectedYear === "all",

0 commit comments

Comments
 (0)