Skip to content

Add a today control and on-idle return to today to the calendar - #144

Merged
jherforth merged 3 commits into
jherforth:mainfrom
mrramam:feature/calendar-today-button
Aug 31, 2026
Merged

Add a today control and on-idle return to today to the calendar#144
jherforth merged 3 commits into
jherforth:mainfrom
mrramam:feature/calendar-today-button

Conversation

@mrramam

@mrramam mrramam commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

A wall display left on last month looks current and is not.

Today control — the period label is now a button; tapping it returns to today, and it goes inert (reading · Today) when already there. Desktop keeps a separate 📅 button; on a phone the header has no room for one, so the label carries it alone. It's a ButtonBase, so keyboard reachable.

Idle auto-return — returns to today after a configurable idle period, default 20 minutes, 0 or empty disables. Stored per device in calendarWidgetSettings.idleReturnMinutes. Any interaction restarts the countdown; the timer clears on unmount and doesn't run while the browser tab is hidden. Only the date resets — a household that chose week view keeps it.

One behaviour worth flagging: the countdown restarts rather than resumes when a hidden browser tab becomes visible. Invisible on a kiosk, but it means auto-return rarely fires on a phone that backgrounds often. Happy to change it to pause if you'd prefer.

Pure helpers are in utils/calendarIdleReturn.js with tests. features.md updated.

Tested on a real instance at desktop and phone widths, both themes. Node 20 (matching ci-tests.yml): client 144, server 190, check:i18n 715/715, build clean.

A wall display left on last month looks current and is not.

The period label doubles as a "today" button — tapping it returns to today, and
it goes inert (reading "· Today") when already there. Desktop also gets a
separate 📅 button; on a phone the header has no room for one, so the label
carries it alone. It is a ButtonBase, so it is keyboard reachable.

Auto-return brings the view back to today after a configurable idle period
(default 20 minutes, 0 or empty disables), stored per device in
calendarWidgetSettings.idleReturnMinutes. Any interaction restarts the
countdown; the timer is cleared on unmount and does not run while the browser
tab is hidden. Only the date is reset — a household that chose week view keeps
it.

Note the countdown restarts rather than resumes when a hidden browser tab
becomes visible again. That is invisible on a kiosk but means auto-return
rarely fires on a phone that backgrounds often; pausing instead would be a
reasonable change if that matters.

Pure helpers (duration parsing, same-day comparison) are in
utils/calendarIdleReturn.js with tests.
@mrramam mrramam changed the title Add a today control and idle auto-return to the calendar Add a today control and on-idle find today to the calendar Aug 29, 2026
@mrramam mrramam changed the title Add a today control and on-idle find today to the calendar Add a today control and on-idle return to today to the calendar Aug 29, 2026
The isViewingToday flag is derived from currentDate, which is set once
at mount and never rolls over at midnight. After midnight, the header
would claim a stale date is today, and the Today control would stay
disabled exactly when the user most wants to tap it.

Remove the '· Today' indicator appended to the period label, drop the
disabled prop and its associated Tooltip suppression props and dead
Mui-disabled styling from both the label ButtonBase and the desktop
Today IconButton, and remove the Box wrapper that existed solely to
give MUI's Tooltip a non-disabled child (moving the responsive display
style directly onto the IconButton). Delete the widget.todayIndicator
i18n key from en and es locales. goToToday's early-return guard and
isViewingToday itself are preserved — the idle auto-return effect
still uses the flag and staleness there is harmless.
The today control compared currentDate against a new Date() captured at
render. A display with refresh disabled can cross midnight without
re-rendering, leaving the comparison stale-true and the control inert
at the moment it is actually needed. Evaluate now inside the handler,
and mark activity on every tap since the user did interact.
@jherforth jherforth added this to the 1.8 milestone Aug 31, 2026
@jherforth jherforth added the bug Something isn't working label Aug 31, 2026
@jherforth
jherforth merged commit d8b8eaa into jherforth:main Aug 31, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in HomeGlow Kanban Aug 31, 2026
jherforth added a commit that referenced this pull request Aug 31, 2026
…live (#144 follow-up)

features.md said the period label goes "Inert when already there". It did in the
first commit of #144, and the contributor removed it two commits later under the
apt title "remove stale 'today' assertion from header" — the docs just did not
follow.

Removing it was right. Whether the view is on today is computed at render, so a
display sitting on today across midnight would keep asserting "Today" while
showing yesterday: precisely the stale-wall-display problem the PR set out to
fix, reintroduced in the label. The control now evaluates the date at click time
and stays live, which is worth writing down so nobody "fixes" it back.

Docs only; no behaviour change.
@jherforth

Copy link
Copy Markdown
Owner

Merged. The two follow-up commits are the best part of this — catching that a rendered "Today" assertion goes stale across midnight, on a feature whose whole point is that stale wall displays lie, is a nice bit of self-review.

One tidy-up pushed in 4539c70: features.md still said the label is "Inert when already there", which was true of the first commit but not after e15a36f. Replaced with a note on why it's deliberately always live, so nobody helpfully restores the disabled state later.

Two things I left alone, both deliberate on your part and I agree with them:

  • The idle countdown restarting rather than resuming on tab focus. You flagged it; for a kiosk it's invisible, and pausing would mean tracking elapsed time across visibility changes for a case the feature isn't aimed at. Not worth the complexity.
  • Auto-return moving the date but not the view. Flipping a household's chosen week view back to month would be a second surprise on top of the first.

Verified merged with main rather than the branch alone: 130 client, 208 server, i18n 721/721, build clean, no conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants