Skip to content

feat(Range/DateField): support intering invalid dates#268

Open
ValeraS wants to merge 2 commits intomainfrom
feat/issue-83
Open

feat(Range/DateField): support intering invalid dates#268
ValeraS wants to merge 2 commits intomainfrom
feat/issue-83

Conversation

@ValeraS
Copy link
Collaborator

@ValeraS ValeraS commented Feb 7, 2026

Temporarily allow incomplete or invalid date inputs—where some fields are empty or the entered date/time doesn’t exist (for example, February 31 or 2:00am during a forward DST shift). Rather than forcing the value to be valid while the user is typing, we hold these intermediate values internally and don’t emit them via onChange until the user blurs the field. On blur, we normalize the input to a valid date/time.

This makes it easier to edit dates that are briefly invalid during normal typing (like changing the day before updating the month). We still emit onChange in real time whenever we can, but not when the displayed value is incomplete or invalid.

BREAKING CHANGES:

  • state returned by useDateFieldState/useRangeDateFieldState is
    changed;

This is part 1 of 1 in a stack made with GitButler:

@ValeraS ValeraS linked an issue Feb 7, 2026 that may be closed by this pull request
@ValeraS ValeraS changed the title feat(Date/RangeField): support intering invalid dates feat(RangeDate/Field): support intering invalid dates Feb 7, 2026
@ValeraS ValeraS changed the title feat(RangeDate/Field): support intering invalid dates feat(Range/DateField): support intering invalid dates Feb 7, 2026
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 62.21% 1561 / 2509
🔵 Statements 62.34% 1591 / 2552
🔵 Functions 63.04% 302 / 479
🔵 Branches 56.9% 1253 / 2202
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/components/DateField/DateField.tsx 100% 85.71% 100% 100%
src/components/DateField/IncompleteDate.ts 95.55% 90% 100% 95.34% 72, 117
src/components/DateField/types.ts 100% 100% 100% 100%
src/components/DateField/utils.ts 81.04% 66.9% 100% 80.6% 106-115, 163-166, 231, 251, 259, 261, 279-284, 291-292, 304, 308, 324-330, 366-374, 380-386, 398-399, 408-413, 415-420, 460, 476, 526, 544-548, 563, 571, 587, 609, 676, 724, 734-737, 743, 775, 788, 873-874
src/components/DateField/hooks/useBaseDateFieldState.ts 56.79% 48.66% 72.72% 57.23% 184, 194-201, 206, 216-223, 228, 240-248, 254, 259-260, 265, 277, 285, 290, 307-320, 322-326, 352-378, 390, 397-398, 406
src/components/DateField/hooks/useDateFieldProps.ts 61% 63.63% 78.57% 61% 57, 117, 124, 130, 155-156, 158-159, 161-162, 164-165, 170-171, 173-174, 176-177, 179-180, 182-199, 209-240
src/components/DateField/hooks/useDateFieldState.ts 83.95% 84.09% 82.35% 83.75% 65, 130-138, 143, 150-151, 185-189, 199, 204
src/components/HiddenInput/HiddenInput.tsx 100% 100% 100% 100%
src/components/RangeDateField/RangeDateField.tsx 100% 92.3% 100% 100%
src/components/RangeDateField/hooks/useRangeDateFieldState.ts 90.58% 86.66% 94.11% 90.47% 126-134, 139, 230, 235
src/components/RangeDateField/utils/getRangeEditableSections.ts 100% 90% 100% 100%
src/components/RangeDatePicker/RangeDatePicker.tsx 100% 81.25% 100% 100%
Generated in workflow #31 for commit dc73f11 by the Vitest Coverage Report Action

@gravity-ui-bot
Copy link
Contributor

gravity-ui-bot commented Feb 7, 2026

🎭 Tests Report is ready.
🎭 Coverage Report is ready.

@ValeraS ValeraS marked this pull request as ready for review February 7, 2026 17:10
@ValeraS ValeraS requested review from amje and korvin89 as code owners February 7, 2026 17:10
Temporarily allow incomplete or invalid date inputs—where some fields
are empty or the entered date/time doesn’t exist (for example, February
31 or 2:00am during a forward DST shift). Rather than forcing the value
to be valid while the user is typing, we hold these intermediate values
internally and don’t emit them via onChange until the user blurs the
field. On blur, we normalize the input to a valid date/time.This makes
it easier to edit dates that are briefly invalid during normal typing
(like changing the day before updating the month). We still emit
onChange in real time whenever we can, but not when the displayed value
is incomplete or invalid.

BREAKING CHANGES:
 - state returned by `useDateFieldState`/`useRangeDateFieldState` is
   changed;
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.

It's not possible to enter 31 of may in the dd.mm.yyyy format

3 participants