Skip to content

fix(DatePicker): error handling & a11y polish#3395

Draft
aresnik11 wants to merge 2 commits into
mainfrom
ajr-datepicker-polish-new
Draft

fix(DatePicker): error handling & a11y polish#3395
aresnik11 wants to merge 2 commits into
mainfrom
ajr-datepicker-polish-new

Conversation

@aresnik11

@aresnik11 aresnik11 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds per-input validation error messages to DatePicker:

  • Per-input errors — each DatePickerInput manages its own error, so range mode shows independent messages for the start and end inputs. Typed dates are validated on change and blur; invalid input stays visible until corrected.
  • No-shift input layout — the error renders via FormError's absolute variant so the input never changes height: the range-mode arrow stays aligned and no space is reserved when there's no error.
  • Calendar offset — the popover shifts down only when it's open and an error exists (via a hasError context flag); closed-state spacing is unchanged.
  • Validation util — detects incomplete entries, invalid month/day, date rollover (e.g. Feb 30), and disabled dates.
  • Localizable strings — new DatePickerTranslations keys for each error message, with English defaults.

Also adds some calendar/input accessibility refinements:

  • Announce full weekday names in calendar headers instead of abbreviations
  • Associate the field label with the segment shell via aria-labelledby
  • Convert the presentational calendar icon to an IconButton with an openCalendarLabel translation

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: [ABC-123]
  • Version plan added/updated (or not needed)
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Single mode

  1. Type 2/30/2024 and blur → shows "February does not have 30 days".
  2. Correct to 2/28/2024 → error clears and the date commits.
  3. Open/close the calendar several times → spacing above it stays consistent.
  4. With a disableDate prop, type a disabled date → shows "This date is not available".

Range mode

  1. Start input: type 2/30/2024 → error appears under the start input only.
  2. End input: type an invalid date → a separate error appears under the end input.
  3. Confirm the arrow separator does not move when errors appear/disappear.
  4. Correct the start date → start error clears while the end error (if any) remains.

Calendar + spacing

  1. Open the calendar with no error and note the spacing above it.
  2. Trigger an error while it's open → the calendar shifts down so the error is visible.
  3. Close and reopen → spacing matches step 9 (no drift).

Accessibility

  1. Each error announces via its role="alert" region; start/end errors announce independently.
  2. aria-invalid toggles on each input as its error state changes.
  3. Calendar weekday headers announce full weekday names (e.g. "Monday").

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

… button

- Announce full weekday names in calendar headers instead of abbreviations
- Associate the field label with the segment shell via aria-labelledby
- Convert the presentational calendar icon to an IconButton with an
  openCalendarLabel translation

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nx-cloud

nx-cloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 7f941b4


☁️ Nx Cloud last updated this comment at 2026-07-13 21:11:33 UTC

@nx-cloud

nx-cloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 81bac52


☁️ Nx Cloud last updated this comment at 2026-07-07 19:14:44 UTC

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.18868% with 74 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.06%. Comparing base (b578661) to head (7f941b4).
⚠️ Report is 5 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...src/DatePicker/DatePickerInput/utils/validation.ts 15.62% 54 Missing ⚠️
...ges/gamut/src/DatePicker/DatePickerInput/index.tsx 48.71% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3395      +/-   ##
==========================================
- Coverage   90.55%   89.06%   -1.50%     
==========================================
  Files         398      271     -127     
  Lines        6586     5761     -825     
  Branches     2131     1944     -187     
==========================================
- Hits         5964     5131     -833     
- Misses        613      621       +8     
  Partials        9        9              
Flag Coverage Δ
main ?
pull-request 89.06% <30.18%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Move error state to each DatePickerInput so start/end inputs in range
mode surface independent messages. Render the error via FormError's
`absolute` variant so it sits out of layout flow — the input never
changes height, keeping the range-mode arrow aligned and reserving no
space when there is no error. The calendar popover still shifts down
(y=0) only when open and an error exists, via a boolean `hasError`
context signal.

Validate typed dates (incomplete, invalid month/day, rollover, disabled
dates) through a shared validateSegments util and localizable
translation keys.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecademydev

Copy link
Copy Markdown
Collaborator

📬 Published Alpha Packages:

Package Version npm Diff
@codecademy/gamut 72.2.3-alpha.303f64.0 npm diff
@codecademy/gamut-icons 9.57.10-alpha.303f64.0 npm diff
@codecademy/gamut-illustrations 0.58.16-alpha.303f64.0 npm diff
@codecademy/gamut-kit 3.0.7-alpha.303f64.0 npm diff
@codecademy/gamut-patterns 0.10.35-alpha.303f64.0 npm diff
@codecademy/gamut-styles 20.0.3-alpha.303f64.0 npm diff
@codecademy/gamut-tests 6.0.6-alpha.303f64.0 npm diff
@codecademy/variance 0.26.2-alpha.303f64.0 npm diff
eslint-plugin-gamut 2.4.4-alpha.303f64.0 npm diff

@aresnik11 aresnik11 changed the title fix(DatePicker): a11y polish for weekday headers, label, and calendar… fix(DatePicker): error handling & a11y polish Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

2 participants