From 5f5ddd37a63dc1c621c4b4f0ad27ba1f8f6046ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 9 Oct 2026 10:05:06 +0200 Subject: [PATCH] fix(timeline): keep "No entries" for a bucket with nothing in it A bucket that holds a mean but no lane entry is not empty; the means say what it holds. The bar opened on such a bucket by default and called it empty beside its own values. --- .../timeline/__tests__/timeline-components.test.tsx | 9 +++++++++ src/components/timeline/selection-bar.tsx | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/timeline/__tests__/timeline-components.test.tsx b/src/components/timeline/__tests__/timeline-components.test.tsx index 67b709c38..5a1ffdfb8 100644 --- a/src/components/timeline/__tests__/timeline-components.test.tsx +++ b/src/components/timeline/__tests__/timeline-components.test.tsx @@ -320,6 +320,15 @@ describe("selection bar head and hint", () => { expect(text(html)).toContain("Erkältung · 31. Dez. bis 8. Jan."); }); + it("calls a bucket empty only when it holds neither an entry nor a value", () => { + // July 2026: no entry, but a systolic mean. + expect(bar("2026-07-15")).not.toContain("timeline-selection-empty"); + // May 2026: no entry, no value. + expect(text(bar("2026-05-10"))).toContain( + "Keine Einträge in diesem Zeitraum", + ); + }); + it("says how to pick a day only until one is picked", () => { expect(bar("2026-01-03", fullTimeline(), true)).toContain( 'data-slot="timeline-selection-hint"', diff --git a/src/components/timeline/selection-bar.tsx b/src/components/timeline/selection-bar.tsx index 4b2b7cc73..de5bbeaf0 100644 --- a/src/components/timeline/selection-bar.tsx +++ b/src/components/timeline/selection-bar.tsx @@ -73,6 +73,9 @@ export function SelectionBar({ const periodTo = dayKey(dayNumber(bucketAfter(periodFrom, bucket)) - 1); const entries = itemsInPeriod(timeline.lanes, periodFrom, periodTo, today); const means = bucketValues(timeline.series, timeline.bucket, selected); + // A bucket with a value but no entry is not empty: the means below say + // what it holds, so "No entries" is kept for a stretch with nothing. + const hasValue = means.values.some((v) => v.mean !== null); // "Ø {values}": the words around the values, so the values can carry // their colour dots. const [meanBefore, meanAfter = ""] = t("timeline.selection.mean", { @@ -109,7 +112,7 @@ export function SelectionBar({ > {bucketTitle(periodFrom, bucket, intl, t)} - {entries.length === 0 && ( + {entries.length === 0 && !hasValue && (