diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b9ac6ba7..55aa1b220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,18 @@ sent. The Background jobs card on the admin status page now lists the same runs the alert counts, and both say in words what failed and which provider. (#1384) +- **Switching records with HealthLog open in a second tab.** Switching + into or out of a shared record could leave both tabs on the loading + spinner, and a reload within the next half minute did not help. An + account check the switching tab had started just before the switch + could answer for the record being left and undo the switch the other + tabs were waiting for. Such an answer is now thrown away and asked + again. +- **Charts no longer jump while they load.** The placeholder of every + chart that links its days was 20 px taller than the chart it turned + into (40 px on a phone), and the mood chart's placeholder was about + 30 px shorter, so the dashboard and the metric pages shifted under you + when the charts arrived. ### Security diff --git a/e2e/tablet-shell.spec.ts b/e2e/tablet-shell.spec.ts index ddd77e8a7..6f67b9cbb 100644 --- a/e2e/tablet-shell.spec.ts +++ b/e2e/tablet-shell.spec.ts @@ -54,6 +54,42 @@ async function openDashboard(page: Page) { ).toBeVisible(); // The module-gated destinations join the rail once `/api/auth/me` lands. await expect(page.locator('aside nav a[href="/medications"]')).toHaveCount(1); + await expectChartRowSettled(page); +} + +/** + * The dashboard's chart row has swapped every loading shell for its chart. + * + * The charts are one lazily loaded chunk, and each cell holds a skeleton until + * it lands and the row reveals. The swap changes the row's height, so a page + * measured before it is not the page the reader ends up with: on a loaded + * runner the chunk arrived a second after the dashboard painted, after + * `scrollMainToEnd` had already seen two equal heights, and `
` was no + * longer at its end when it was measured. Waited for on the cells' own state + * rather than on time. + */ +async function expectChartRowSettled(page: Page) { + await expect + .poll( + () => + page.evaluate(() => { + const main = document.getElementById("main-content")!; + const cells = main.querySelectorAll( + '[data-slot="dashboard-chart-cell"]', + ); + const held = main.querySelectorAll( + '[data-slot="dashboard-chart-cell"]:not([data-revealed="true"])', + ); + const shells = main.querySelectorAll('[data-slot="chart-skeleton"]'); + return { + cells: cells.length > 0, + held: held.length, + shells: shells.length, + }; + }), + { timeout: 15_000 }, + ) + .toEqual({ cells: true, held: 0, shells: 0 }); } /** The shell fills the window exactly and the document has nothing to scroll. */ diff --git a/src/app/insights/mood/page-client.tsx b/src/app/insights/mood/page-client.tsx index 00c75e12d..fa0f048cc 100644 --- a/src/app/insights/mood/page-client.tsx +++ b/src/app/insights/mood/page-client.tsx @@ -12,7 +12,10 @@ import { queryKeys } from "@/lib/query-keys"; import { useTranslations } from "@/lib/i18n/context"; import { useInsightsLayoutPrefs } from "@/hooks/use-insights-layout-prefs"; import { Button } from "@/components/ui/button"; -import { ChartSkeleton } from "@/components/charts/chart-skeleton"; +import { + ChartSkeleton, + MoodChartSkeleton, +} from "@/components/charts/chart-skeleton"; import { MetricEmptyState } from "@/components/insights/metric-empty-state"; import { MetricTargetSummary } from "@/components/insights/metric-target-summary"; import { @@ -54,7 +57,7 @@ const MoodChart = dynamic( import("@/components/charts/chart-runtime").then((mod) => ({ default: mod.MoodChart, })), - { ssr: false, loading: () => }, + { ssr: false, loading: () => }, ); /** diff --git a/src/components/charts/chart-skeleton.tsx b/src/components/charts/chart-skeleton.tsx index f160a07b3..828c24630 100644 --- a/src/components/charts/chart-skeleton.tsx +++ b/src/components/charts/chart-skeleton.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from "react"; +import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { cn } from "@/lib/utils"; import { useTranslations } from "@/lib/i18n/context"; @@ -50,12 +51,16 @@ const SLOW_HINT_DELAY_MS = 3_000; /** * The footer a loaded `` paints under its plot: the row of day - * dots and its caption on a day-linked chart, and the collapsed "show as - * table" disclosure. A loading shell without it was ~100 px shorter than the - * card it turned into (CLS on every metric page, the BMI page most visibly), - * so the shells reserve the same boxes: `h-3` rug, `mt-1` caption (two lines - * on a phone, one from `sm`), and the disclosure's `mt-3 border-t pt-3` frame - * around its `min-h-11` button. + * dots on a day-linked chart, and the collapsed "show as table" disclosure. A + * loading shell without it was ~100 px shorter than the card it turned into + * (CLS on every metric page, the BMI page most visibly), so the shells reserve + * the same boxes: the `h-3` rug, and the disclosure's `mt-3 border-t pt-3` + * frame around its `min-h-11` button. + * + * The rug is all a day-linked chart paints under its plot. It used to carry a + * one-line caption as well, and the reserve kept that line after the caption + * went: every day-linked shell stood 20 px taller than its chart (40 px on a + * phone) and the page shrank under the reader when the chart arrived. */ export function ChartFooterReserve({ dayLinks = false, @@ -67,12 +72,7 @@ export function ChartFooterReserve({ if (!dayLinks && !dataTable) return null; return (