Skip to content

fix(date-window-dialog): own name state, self-validate, and redesign the form - #84

Merged
buggedcom merged 1 commit into
mainfrom
feat/date-window-dialog-70
Oct 19, 2026
Merged

buggedcom merged 1 commit into
mainfrom
feat/date-window-dialog-70

Conversation

@buggedcom

Copy link
Copy Markdown
Owner

Closes #70

Problem

The date-window dialog (opened from the comparison-tab rail +) had two user-facing bugs and a cramped layout:

  1. Name silently wiped — typing a name then nudging the dates or dragging the range timeline erased it. The name field was bound .value=${this.name} with no change handler, so every parent re-render re-applied the stale prop.
  2. "Create date window" appeared to do nothing — with an empty name or an invalid range the panel returned early with no feedback, and nobody called shake().

Solution

Ownership of name state and validation moves into the date-window-dialog molecule (single seam), per the spec's agreed design.

  • Name is dialog-internal. The name prop now only seeds internal _nameValue on the open false→true transition (via willUpdate/_wasOpen); the user's typed value is authoritative thereafter, so parent re-renders no longer clobber it.
  • Self-validation + shake on submit. Submit validates a non-empty trimmed name and a parseable start strictly before end. Invalid submits shake, surface a localized inline error keyed to the offending field (and focus it for screen-reader announcement), and do not emit dp-window-submit; the dialog stays open. The error clears once the field is corrected. Only valid submits emit { name, start, end }.
  • Visual redesign of date-window-dialog.styles.ts — grouped name / date-range (start + end + timeline) / shortcuts / actions sections, timeline breathing room, emphasised primary button with a separated destructive Delete, and preserved @media (max-width: 720px) stacking.
  • Panel simplification — _createDateWindowFromDialog's guard is now a defensive assertion; the panel keeps owning the draft range, start/end, bounds, zoom and snapping, plus close/delete/shortcut/date-change handling. Event shapes are unchanged.
  • i18n — both new error strings added across de/es/fi/fr/pt/zh-hans. New context.md documents the ownership model.

Tests

  • date-window-dialog.spec.ts (molecule seam): name persistence across stale re-renders, invalid submit (empty name / bad range) → no emit + shake + inline error, error clears on correction, edit-mode prefill preserved, happy-path valid submit.
  • Panel happy-path coverage (datapoints-mounted-dialogs.spec.ts) unchanged — validity is now guaranteed before the event fires.
  • Stories: EmitsSubmit uses a valid named window; added InvalidSubmitShowsError; added a setFrontendLocale locale loader.

Verified locally: tsc, eslint, prettier, the dialog + translation-coverage + panel-dialog unit specs, and all Storybook interaction tests pass.

⚠️ The visual redesign will produce Chromatic diffs that need human baseline approval.

🤖 Generated with Claude Code

…the form

The date-window dialog had two user-facing bugs and a cramped layout:

- Typing a name then nudging the dates or dragging the range timeline wiped
  the name, because the name field was bound `.value=${this.name}` with no
  change handler and every parent re-render re-applied the stale prop.
- Clicking "Create date window" with an empty name or an invalid range did
  nothing — the panel returned early with no feedback and nobody called
  `shake()`.

Move name ownership and validation into the molecule (single seam):

- The `name` prop now only seeds internal `_nameValue` state on the open
  transition (via `willUpdate`); the user's typed value is authoritative
  thereafter, so parent re-renders no longer clobber it.
- Submit self-validates (non-empty trimmed name, start strictly before end).
  Invalid submits shake the dialog and show a localized inline error keyed to
  the offending field, and do not emit `dp-window-submit`. The error clears
  once the field is corrected. Only valid submits emit `{ name, start, end }`.
- Fuller visual redesign: grouped name / date-range (start+end+timeline) /
  shortcuts / actions sections, timeline breathing room, emphasised primary
  button with a separated destructive Delete, and preserved mobile stacking.
- Panel's `_createDateWindowFromDialog` guard is now a defensive assertion;
  the panel no longer feeds a controlled name back into the dialog.
- New error strings localized across de/es/fi/fr/pt/zh-hans; context.md added.

Covered by molecule tests at the dialog seam (name persistence, invalid
submit + shake + inline error, error clearing, edit-mode prefill) plus an
invalid-state story; existing panel happy-path coverage unchanged.

Closes #70

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@buggedcom
buggedcom merged commit 1fbc7b2 into main Oct 19, 2026
14 of 15 checks 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.

the date window dialog is broken

1 participant