Repository navigation
refactor(date-picker, date-range-picker): select the typed date in the calendar - #2650
Merged
Merged
Conversation
…lendar While you type, the calendar now selects a complete typed date. While the date is incomplete or not valid, it keeps its last selection, and an empty input clears it. In the date range picker, each end follows its own text. The value still changes only when the edit is committed. Fixes: - A prompt that is also a separator of the input format, such as "-" with yyyy-MM-dd, no longer makes a complete date look incomplete. - In the date picker, the input and change events of slotted content go on to the application and no longer change the value. Also cleans up the date editors and parsers. The range parser uses one date parser for both ends, the editor's "draft" methods are now named "edit", and the comments are shorter.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Outstanding issues include a no-op step resetting the calendar out of sync with uncommitted input and a public parsing-state hook that violates the cross-component access guidelines.
2 open issues
What changed in this PR
Updates the date picker and date range picker so calendar selections follow complete typed dates without committing the value. Incomplete or invalid edits retain the previous selection, while blank input clears the corresponding selection.
Changes:
- Synchronizes calendar selections with edits, commits, focus changes, and form resets.
- Fixes prompt characters that overlap separators and preserves events from slotted date-picker content.
- Consolidates range parsing and expands regression tests, property-based tests, specifications, and release notes.
| File | Description |
|---|---|
| src/internals/testing/simulate.spec.ts | Adds a Backspace selection helper. |
| src/internals/mixins/mask-behavior.ts | Updates edit-related comments. |
| src/components/date-time-input/spec.md | Documents edit parsing and prompt handling. |
| src/components/date-time-input/datetime-mask-parser.ts | Adds edit parsing and part-aware completeness checks. |
| src/components/date-time-input/datetime-mask-parser.spec.ts | Tests edit parsing and separator prompts. |
| src/components/date-time-input/datetime-mask-parser.property.spec.ts | Checks prompt handling across generated formats. |
| src/components/date-time-input/date-time-input.base.ts | Exposes edit parsing and renames internal edit methods. |
| src/components/date-time-input/date-part.ts | Consolidates part types and range validation. |
| src/components/date-range-picker/spec.md | Documents per-end calendar selection behavior. |
| src/components/date-range-picker/range-shape.ts | Normalizes range order for calendar binding. |
| src/components/date-range-picker/range-shape.spec.ts | Tests reversed range normalization. |
| src/components/date-range-picker/range-editors.ts | Reads each editor’s retained selection. |
| src/components/date-range-picker/range-editors.spec.ts | Tests incomplete, blank, and reversed edits. |
| src/components/date-range-picker/date-range-picker.ts | Tracks typed selections independently by end. |
| src/components/date-range-picker/date-range-picker.form.spec.ts | Tests selection restoration on reset. |
| src/components/date-range-picker/date-range-picker-two-inputs.spec.ts | Tests selection retention and focus transitions. |
| src/components/date-range-picker/date-range-picker-single.spec.ts | Tests per-end selection in single-input mode. |
| src/components/date-range-picker/date-range-mask-parser.ts | Reuses one date parser and adds per-end edit parsing. |
| src/components/date-range-picker/date-range-mask-parser.spec.ts | Tests prompts within range separators. |
| src/components/date-range-picker/date-range-mask-parser.property.spec.ts | Checks per-end edit parsing properties. |
| src/components/date-range-picker/date-range-input.ts | Removes redundant overrides and shortens documentation. |
| src/components/date-picker/value-shape.ts | Reuses the empty calendar dates array. |
| src/components/date-picker/spec.md | Documents typed selections and slotted events. |
| src/components/date-picker/date-picker.ts | Binds typed selections and guards editor events. |
| src/components/date-picker/date-picker.spec.ts | Tests selection lifecycle and slotted events. |
| src/components/date-picker/date-picker.base.ts | Centralizes selection lifecycle and event ownership. |
| src/components/date-picker/date-picker-form.spec.ts | Tests selection restoration after form reset. |
| CHANGELOG.md | Records selection, prompt, and event fixes. |
Review effort: Balanced
| /** Takes the value of the input after a call that ends its edit, so the calendar shows it too. */ | ||
| private _takeInputValue(): void { | ||
| this.value = this._input.value; | ||
| this._editValue = undefined; |
Comment on lines
+132
to
+134
| * @hidden @internal | ||
| */ | ||
| public _parseEdit(previous: T | null): T | null { |
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.


Description
While you type, the calendar now selects a complete typed date. While the date is incomplete or not valid, it keeps its last selection, and an empty input clears it. In the date range picker, each end follows its own text. The value still changes only when the edit is committed.
Fixes:
Also cleans up the date editors and parsers. The range parser uses one date parser for both ends, the editor's "draft" methods are now named "edit", and the comments are shorter.
Type of Change
Checklist
CHANGELOG.mdentry under[Unreleased]