Repository navigation
fix(calendar): merge consumer classNames and formatters with defaults - #905
Open
rashmi09-sys wants to merge 1 commit into
Open
rashmi09-sys wants to merge 1 commit into
rashmi09-sys wants to merge 1 commit into
Conversation
Calendar built its classNames from its own default keys only, so a class for any DayPicker part without a coss default (root, weekdays, selected, month_grid, ...) was silently dropped. Passing any formatters also replaced the default formatMonthDropdown, so the month dropdown switched from short to long names. Start the classNames merge from the consumer's classes and spread consumer formatters over the default. Parts coss styles merge exactly as before; a key set to undefined counts as not provided. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011axzxSXXTqZnzgb8feHHdD
|
@rashmi09-sys is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
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.
Problem
Calendarsilently drops two kinds of consumer customisation:classNamesfor parts without a coss default are ignored. Only the 20 parts coss styles are merged, so classes for any other DayPicker part (root,weekdays,selected,month_grid,focused,footer, …) never reach DayPicker. The docs describeclassNamesas "Custom class names for calendar parts", and passing the same object toDayPickerdirectly applies all of them.formattersprop replaces the default month formatter. Passing an unrelated formatter (e.g.formatWeekdayName) switches the month dropdown from "Jan" back to "January", undoing the short labels from fix(calendar): format month dropdown with the DayPicker locale #890. PassingformatMonthDropdown: undefinedwith a dropdown caption throwsTypeError: formatters.formatMonthDropdown is not a function.Reproduction
Or run the new tests against
main'scalendar.tsx:bun test packages/ui/test/components/calendar.test.tsx→ 4 of 8 fail.Root cause
Fix
classNamesreduce with the consumer's classes, so parts without a coss default keep them. Parts coss styles still merge throughcn, unchanged.formattersand spread it over the default, so an unrelated formatter keepsformatMonthDropdownand a consumerformatMonthDropdownstill wins.undefinedas not provided (small localwithoutUndefinedhelper). Without it,classNames={{ weekdays: undefined }}would clear DayPicker's ownrdp-weekdaysclass, whichmainkeeps, and an undefined formatter would still throw.Changed: both
calendar.tsxcopies (viaui:sync),public/r/calendar.json(viaregistry:build) and a new test file.registry:buildalso rewrites ~30 unrelated particle JSON files that have already drifted onmain; they are left out, as in #890. No new dependencies, no API or docs changes.Tests
New
packages/ui/test/components/calendar.test.tsx(8 tests, samebun:test+ dynamic-import style as the existing component tests):mainformattersor one formatter isundefinedtext-lgovertext-sm)undefined,{}andundefinedvaluesThe last four guard existing behaviour. Other suites mock
cnas a plain join and Bun module mocks persist across files, so this file restores the realclsx+tailwind-mergecnfor itself; it passes in 78 randomized file orders.CI commands run locally:
bun install --frozen-lockfile,bunx biome check --linter-enabled=false .,bun run lint,bun run typecheckandbun run test(49 pass, 0 fail) all pass, as doturbo run build --filter=uiandregistry:validate-deps. The fullbun run builddid not complete locally: theoriginapp failed fetching Google Fonts in a network-restricted environment, sowwwand the examples app were not built; CI will cover them.Compatibility
mainand this branch, as do default, dropdown-caption and range calendars.rdp-*class for that part.Visual evidence
Rendered in Chromium with coss

globals.csscompiled by Tailwind v4: classes onweekdays,selectedandmonth_grid(as above, with a ring offset and outline colour for visibility), plusformatWeekdayNameand a dropdown caption:AI assistance
Investigated, implemented and tested with Claude Code (Claude Opus 5.5); I reviewed the change and the evidence. The commit carries a
Co-Authored-Bytrailer.