Repository navigation
fix(date-window-dialog): own name state, self-validate, and redesign the form - #84
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #70
Problem
The date-window dialog (opened from the comparison-tab rail +) had two user-facing bugs and a cramped layout:
.value=${this.name}with no change handler, so every parent re-render re-applied the stale prop.shake().Solution
Ownership of name state and validation moves into the
date-window-dialogmolecule (single seam), per the spec's agreed design.nameprop now only seeds internal_nameValueon the open false→true transition (viawillUpdate/_wasOpen); the user's typed value is authoritative thereafter, so parent re-renders no longer clobber it.dp-window-submit; the dialog stays open. The error clears once the field is corrected. Only valid submits emit{ name, start, end }.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._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.context.mddocuments 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.datapoints-mounted-dialogs.spec.ts) unchanged — validity is now guaranteed before the event fires.EmitsSubmituses a valid named window; addedInvalidSubmitShowsError; added asetFrontendLocalelocale loader.Verified locally:
tsc, eslint, prettier, the dialog + translation-coverage + panel-dialog unit specs, and all Storybook interaction tests pass.🤖 Generated with Claude Code