Skip to content

fix(calendar): correct today highlight and separate from selected state#743

Closed
Valley-15 wants to merge 0 commit intocosscom:mainfrom
Valley-15:fix-calendar-today-highlight
Closed

fix(calendar): correct today highlight and separate from selected state#743
Valley-15 wants to merge 0 commit intocosscom:mainfrom
Valley-15:fix-calendar-today-highlight

Conversation

@Valley-15
Copy link
Copy Markdown
Contributor

@Valley-15 Valley-15 commented Apr 7, 2026

📄 Description

Fixes #742

This PR resolves the issue where the Calendar component incorrectly highlights the "today" date.

Previously:

  • A non-current date (e.g., 5) was incorrectly shown as "today"
  • "today" and "selected" states were visually overlapping

✅ Changes

  • Explicitly set today = new Date() in DayPicker
  • Added proper modifiers.today to track actual current date
  • Separated styling:
    • today → subtle indicator (dot)
    • selected → highlighted background

🧪 Testing

  • Verified current system date is correctly highlighted
  • Selecting another date:
    • does NOT override "today" indicator
  • Tested across navigation between months

📸 Screenshots

Before

  • Incorrect date highlighted as today
image

After

  • Correct current date highlighted
  • Selected date and today are visually distinct
Screenshot 2026-04-07 181014

🧠 Notes

This resolves confusion caused by mixing "selected" and "today" states in the UI.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

@Valley-15 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the pkg:ui label Apr 7, 2026
@devin-ai-integration
Copy link
Copy Markdown
Contributor

Thanks for the contribution! Here's my review:


1. The core fix (today prop) may be unnecessary

react-day-picker v9 already defaults today to dateLib.today() internally (source):

const { ..., today = dateLib.today(), } = props;
const isToday = isSameDay(date, today);

It uses isSameDay for comparison, which handles time normalization. So the explicit setHours(0,0,0,0) normalization shouldn't change behavior. Could you clarify the exact steps to reproduce the original bug? The "before" screenshot shows "5" highlighted, but it's unclear if that's the selected date being confused with the today indicator vs. an actual today modifier bug.

2. Unrelated regression: dropdown_root SVG styles removed

The PR removes these classes from dropdown_root:

[&_svg:not([class*='opacity-'])]:opacity-80
[&_svg:not([class*='size-'])]:size-4.5
sm:[&_svg:not([class*='size-'])]:size-4
[&_svg]:pointer-events-none
[&_svg]:-me-1

This will break icon sizing/opacity in the month/year dropdown selectors. This change appears unintentional and should be reverted.

3. Formatting changes add noise

The PR reformats the reduce function and removes trailing commas throughout. The project uses Biome with "trailingCommas": "all", so these changes diverge from the project's coding conventions and make the diff harder to review. Please revert the formatting-only changes.

4. Comments with emojis

// ✅ THIS IS THE IMPORTANT PART (today styling)
// ✅ normalize today (avoids timezone issues)

These don't follow the project's commenting style. The code should be self-explanatory — if a comment is needed, keep it concise without emojis (e.g. // Normalize today to midnight to avoid timezone comparison issues). But given point #1, even that may not be warranted.

5. Missing newline at end of file

The PR removes the trailing newline — please restore it.

6. Registry file not updated

The registry copy at apps/ui/registry/default/ui/calendar.tsx is identical to packages/ui/src/components/calendar.tsx and would need the same fix applied if this change is warranted.


Summary: The only functional change (passing today to DayPicker) is likely redundant since the library already defaults to today's date. The PR also introduces an unintended regression (dropdown SVG styles removed), formatting divergence, and noisy comments. I'd suggest:

  1. Provide clear reproduction steps for the original bug
  2. Revert the dropdown_root change
  3. Revert all formatting-only changes
  4. Remove the emoji comments
  5. Restore the trailing newline

@pasqualevitiello
Copy link
Copy Markdown
Contributor

@Valley-15 would you mind to have a look at the review above? Cheers!

@Valley-15
Copy link
Copy Markdown
Contributor Author

ok @pasqualevitiello sir, thanks for your guidance.I will work on the review. Thanks

@Valley-15
Copy link
Copy Markdown
Contributor Author

Hello @pasqualevitiello sir,

I reviewed the issue (#742) and attempted to reproduce it locally using the current codebase.

🧪 Reproduction attempt:

  • Ran the project and navigated to the calendar view (/booking/upcoming?view=calendar)
  • Observed initial render and interacted by selecting multiple dates

🔍 Findings:

  • The current system date is correctly indicated via a dot modifier
  • Selecting a date applies a separate background highlight
  • The "today" indicator remains stable and is not overridden by selection
Screenshot 2026-04-10 112647

📌 Conclusion:

  • The behavior described in the issue does not appear reproducible on the latest code
  • The distinction between "today" (dot) and "selected" (background) is already functioning correctly
  • This aligns with your observation that react-day-picker already handles today internally

⚠️ Additional note:

Given this, the changes introduced in this PR (explicitly setting today) may be redundant and could introduce unnecessary complexity, especially considering the unrelated regressions mentioned in the review.

This suggests the issue may have been:

  • Already resolved upstream, or
  • Based on a misinterpretation of selected vs today states

Thanks!

@Valley-15 Valley-15 closed this Apr 10, 2026
@Valley-15 Valley-15 force-pushed the fix-calendar-today-highlight branch from fcaf926 to 42151c7 Compare April 10, 2026 08:16
@Valley-15 Valley-15 deleted the fix-calendar-today-highlight branch April 17, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix incorrect "today" date highlight in Calendar component

2 participants