mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
fix(mood-chart): make chartKey opt-in and don't leak overlay state across pages
The MoodChart component defaulted chartKey to "mood", which meant every consumer that omitted the prop — including /insights and the recommendation-card mini chart — picked up the dashboard's persisted overlay prefs and rendered the settings cog. Toggling Trend on /insights would silently flip the dashboard mood chart on next paint because both reads shared the same persistence key. Drop the default; the dashboard now passes chartKey="mood" explicitly and ad-hoc surfaces stay clean (no cog, default overlays). Also wraps the title row's right-side container with flex-wrap + justify-end so the 4 range tabs + cog don't push the card horizontally on Pixel-5 when the comparison caption is also in the row. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
720e6c89b9
commit
fbf14fceb8
2 files changed
+19
-9
No files matched your search
+5
-1
@@ -979,7 +979,11 @@ export default function DashboardPage() {
|
||||
order: widgetOrder("mood"),
|
||||
count: moodSummary?.count ?? 0,
|
||||
node: (
|
||||
<MoodChart key="mood-chart" compareBaseline={compareBaseline} />
|
||||
<MoodChart
|
||||
key="mood-chart"
|
||||
compareBaseline={compareBaseline}
|
||||
chartKey="mood"
|
||||
/>
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,7 +77,9 @@ interface MoodChartProps {
|
||||
/**
|
||||
* v1.4.18 — per-chart overlay-prefs key. When supplied, the chart
|
||||
* mounts the overlay-controls dropdown and reads its three toggle
|
||||
* states from the persisted user prefs. Default: "mood".
|
||||
* states from the persisted user prefs. Omit (default) when the
|
||||
* chart is being rendered ad-hoc on /insights or any other read-
|
||||
* only surface — the cog stays hidden and overlays are clean.
|
||||
*/
|
||||
chartKey?: ChartOverlayKey;
|
||||
}
|
||||
@@ -270,7 +272,7 @@ export function MoodChart({
|
||||
mini = false,
|
||||
windowOverride,
|
||||
compareBaseline = "none",
|
||||
chartKey = "mood",
|
||||
chartKey,
|
||||
}: MoodChartProps) {
|
||||
const { isAuthenticated } = useAuth();
|
||||
const { t } = useTranslations();
|
||||
@@ -547,7 +549,7 @@ export function MoodChart({
|
||||
)}
|
||||
</div>
|
||||
{!mini && (
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="flex flex-wrap items-center justify-end gap-1">
|
||||
{TIME_RANGES_KEYS.map((r) => (
|
||||
<Button
|
||||
key={r.labelKey}
|
||||
@@ -562,11 +564,15 @@ export function MoodChart({
|
||||
</Button>
|
||||
))}
|
||||
{/* v1.4.18 — overlay-controls dropdown next to the
|
||||
range tabs. */}
|
||||
<ChartOverlayControls
|
||||
prefs={overlayPrefs.prefs}
|
||||
onChange={overlayPrefs.setPrefs}
|
||||
/>
|
||||
range tabs. Only painted when the chart is bound to
|
||||
a persistent chartKey; ad-hoc usages (/insights mood
|
||||
preview, recommendation card) stay clean. */}
|
||||
{chartKey ? (
|
||||
<ChartOverlayControls
|
||||
prefs={overlayPrefs.prefs}
|
||||
onChange={overlayPrefs.setPrefs}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user