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.
This commit is contained in:
Marc-André Bombeck committed 2026-10-09 10:05:06 +02:00
1 parent 61155d1856
commit 5f5ddd37a6
2 files changed
+13 -1

No files matched your search

@@ -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"',
+4 -1
View File
@@ -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)}
</span>
{entries.length === 0 && (
{entries.length === 0 && !hasValue && (
<span
className="text-muted-foreground text-xs"
data-slot="timeline-selection-empty"