diff --git a/src/shared/components/analytics/charts.tsx b/src/shared/components/analytics/charts.tsx index f1968951d2..a7649305fb 100644 --- a/src/shared/components/analytics/charts.tsx +++ b/src/shared/components/analytics/charts.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState, useMemo, useCallback } from "react"; +import { useState, useMemo, useCallback, useRef, useEffect } from "react"; import { useLocale } from "next-intl"; import Card from "../Card"; import { getModelColor } from "@/shared/constants/colors"; @@ -174,6 +174,8 @@ export function CompactStatGrid({ sections }: { sections: CompactStatSection[] } // ── ActivityHeatmap ──────────────────────────────────────────────────────── export function ActivityHeatmap({ activityMap }) { + const scrollRef = useRef(null); + const cells = useMemo(() => { const today = new Date(); const days = []; @@ -209,6 +211,12 @@ export function ActivityHeatmap({ activityMap }) { return w; }, [cells]); + // Auto-scroll to the right edge so the current date is visible + useEffect(() => { + if (scrollRef.current) { + scrollRef.current.scrollLeft = scrollRef.current.scrollWidth; + } + }, [weeks]); const monthLabels = useMemo(() => { const labels = []; let lastMonth = -1; @@ -259,44 +267,51 @@ export function ActivityHeatmap({ activityMap }) { -
- {monthLabels.map((m, i) => ( - - {m.label} - - ))} -
- -
-
- - Mon - - Wed - - Fri - -
- - {weeks.map((week, wi) => ( -
- {week.map((day, di) => ( -
+
+
+
+ {monthLabels.map((m, i) => ( + + {m.label} + ))}
- ))} + +
+
+ + Mon + + Wed + + Fri + +
+ + {weeks.map((week, wi) => ( +
+ {week.map((day, di) => ( +
+ ))} +
+ ))} +
+