Skip to content

fix(homepage): validate clock widget timezones - #1374

Merged
ZacharyZcR merged 1 commit into
Termix-SSH:dev-2.8.0from
nasif-naseef:fix/clock-invalid-timezone
Aug 31, 2026
Merged

fix(homepage): validate clock widget timezones#1374
ZacharyZcR merged 1 commit into
Termix-SSH:dev-2.8.0from
nasif-naseef:fix/clock-invalid-timezone

Conversation

@nasif-naseef

@nasif-naseef nasif-naseef commented Aug 31, 2026

Copy link
Copy Markdown

Overview

  • Fixed: an invalid timezone on a Clock widget threw RangeError during render and took the homepage canvas down with it
  • Added: timezone validation in the Clock edit dialog, with an inline message and a disabled Save
  • Updated: ClockWidget now falls back to local time for configs already stored with an unusable zone

Changes Made

  • src/ui/features/homepage/clock-timezone.ts (new) — normalizeTimezone, isValidTimezone and validateClockTimezone, shared by the widget and the dialog so the check lives in one place.
  • ClockEditForm.tsx — flags an unusable zone the same way FolderMetadataDialog flags a duplicate folder name: aria-invalid, border-destructive, and an inline text-destructive message.
  • WidgetEditDialog.tsx — one typeId === "clock" branch: Save is disabled while the zone is unusable, handleSave guards again, and the normalized zone is what gets stored, so America/New York is saved as America/New_York instead of being rejected. No other widget form is touched.
  • ClockWidget.tsx — validates before formatting, falling back to local time (and hiding the zone label) for configs saved before this change, so an existing broken homepage recovers on its own.
  • en.json — one new key, homepage.invalidTimezone.
  • Tests — ClockTimezone.test.tsx and WidgetEditDialogClock.test.tsx, 38 assertions covering the widget fallback, the normalizer, the inline error, and Save being blocked and then re-enabled.

Related Issues

Screenshots / Demos

Invalid zone: the field is flagged and Save is disabled, so it can no longer be stored.

invalid zone, error shown, Save disabled

A space instead of an underscore is accepted and normalized on save — no error, Save enabled.

space accepted, Save enabled

Saved result — the widget renders the zone as America/New_York:

widget rendering America/New_York

Before this change, that same config threw during render and took the canvas down with it:

RangeError: Invalid time zone specified: America/New York

Checklist

  • Code follows project style guidelines
  • Supports mobile and desktop UI/app (if applicable)
  • I have read Contributing.md
  • This is not a translation request. See docs

An invalid timezone in a clock widget's config reached toLocaleTimeString
unchecked, throwing RangeError during render and taking the homepage canvas
down with it. The edit dialog accepted any string, so "America/New York" - a
space where IANA wants an underscore - was easy to save, and the homepage
stayed broken on every later load because the value is reloaded from the
database.

The edit dialog now flags an unusable zone the way FolderMetadataDialog flags
a duplicate folder name: inline message, aria-invalid, and a disabled Save.
Whitespace is normalized to underscores on save, so the space spelling is
stored as America/New_York rather than rejected. ClockWidget falls back to
local time for any config already holding an invalid zone.

Related to Termix-SSH/Support#1238

@ZacharyZcR ZacharyZcR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the timezone validation, persisted-config fallback, and test coverage. The focused tests, full frontend suite, type-check, lint, formatting, and diff checks all pass. No blocking changes requested.

@ZacharyZcR
ZacharyZcR merged commit cb49b44 into Termix-SSH:dev-2.8.0 Aug 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants