Skip to content

refactor(date-picker, date-range-picker): select the typed date in the calendar - #2650

Merged
rkaraivanov merged 1 commit into
masterfrom
rkaraivanov/date-picker-typed-selection
Nov 25, 2026
Merged

rkaraivanov merged 1 commit into
masterfrom
rkaraivanov/date-picker-typed-selection

Conversation

@rkaraivanov

Copy link
Copy Markdown
Member

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:

  • 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.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Refactoring (code improvements without functional changes)

Checklist

  • My code follows the project's coding standards
  • I have tested my changes locally
  • I have updated documentation if needed
  • I have added a CHANGELOG.md entry under [Unreleased]

…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.
Copilot AI balanced review requested due to automatic review settings November 25, 2026 09:16
@rkaraivanov
rkaraivanov merged commit 8c06363 into master Nov 25, 2026
11 checks passed
@rkaraivanov
rkaraivanov deleted the rkaraivanov/date-picker-typed-selection branch November 25, 2026 09:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants