mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
fix(coach): keep the chart on "as a table" so the chart is offered back
"As a table" used to drop the table's chart, so the reply offered no way back to it. The copied table now keeps its chart and carries view: table, which the panel opens on the table (the chart one tap away on the toggle) and the chips read to offer "as a chart". show_result with view table does the same. The field is optional on the result metadata; a client that ignores it shows the chart first as before.
This commit is contained in:
1 parent
5e9c4fe8d8
commit
21a2e2fcef
14 files changed
+95
-21
No files matched your search
@@ -108,6 +108,16 @@ describe("CoachResults", () => {
|
||||
expect(tableButton).toContain('aria-pressed="false"');
|
||||
});
|
||||
|
||||
it("opens an 'as a table' answer on the table, with the chart one tap away", () => {
|
||||
const html = results([table({ view: "table" })], "displayed");
|
||||
expect(html).toContain('data-slot="coach-result-table"');
|
||||
expect(html).not.toContain('data-slot="coach-result-chart"');
|
||||
const chartButton = html.match(
|
||||
/<button[^>]*data-slot="coach-result-view-chart"[^>]*>/,
|
||||
)?.[0];
|
||||
expect(chartButton).toContain('aria-pressed="false"');
|
||||
});
|
||||
|
||||
it("opens a table without a chart as a table, with no toggle", () => {
|
||||
const html = results(
|
||||
[table({ chart: null, chartKind: null })],
|
||||
|
||||
@@ -247,8 +247,9 @@ function CoachResultView({
|
||||
const titleId = useId();
|
||||
const reusedLine = useReusedLine(result);
|
||||
const hasChart = result.chart !== null;
|
||||
// "As a table" keeps the chart for the toggle but shows the table first.
|
||||
const [view, setView] = useState<ResultView>(
|
||||
hasChart && chartFirst ? "chart" : "table",
|
||||
hasChart && chartFirst && result.view !== "table" ? "chart" : "table",
|
||||
);
|
||||
if (!hasChart) {
|
||||
return <CoachResultTable result={result} method={reusedLine} />;
|
||||
|
||||
Reference in new issue
Block a user