Skip to content

Conversation

@arefabouhamdan
Copy link
Contributor

@arefabouhamdan arefabouhamdan commented Nov 12, 2025

Description

This PR addresses several issues with the date input component, including timezone handling, default values, year selection, date range presets, and improved date boundary management.

Changes Summary

🐛 Bug Fixes

1. Timezone Fix

  • Issue: Date conversion was using toISOString() which could cause timezone-related date shifts
  • Fix: Changed dateToYYYYMMDD() in helpers.js to use local date components instead of ISO string conversion
  • Impact: Prevents dates from shifting by one day due to timezone conversion issues

2. Default Value Fix

  • Issue: Default value wasn't consistently set to today
  • Fix: Changed default value to use today(getLocalTimeZone()) as the reference date
  • Impact: Date inputs now default to today's date, providing a better user experience

3. Extra Day End String Fix

  • Issue: extraDayEndString was only calculated for range inputs, causing issues with single date inputs
  • Fix: Removed the range condition check so extraDayEndString is calculated for all inputs
  • Impact: Ensures proper date boundary handling for both single date and range inputs, and enables date disabling for dates outside the data range

✨ New Features

4. Data-Driven Year Selection & Date Disabling

  • Feature: Year dropdown now only shows years that exist in the provided data, and dates outside the data range are disabled
  • Implementation:
    • Added data and dates props to extract available years from query data
    • Year options are filtered to only show years present in the dataset
    • Calendar uses calendarStart and calendarEnd (with extraDayEndString for safety) to set minValue and maxValue, which automatically disables dates outside the range
    • Falls back to default behavior if no data is provided
  • Impact: Users can only select years and dates that have data, preventing invalid date selections and improving UX

5. New Date Range Presets

  • Feature: Added "Today" and "Yesterday" presets for quick date selection

6. Improved Preset Calculations

  • Feature: Presets now use a referenceDate that selects the appropriate reference point
  • Implementation:
    • For single date inputs: uses the selected date
    • For range inputs: uses the end date of the selected range
    • "Month to Today" and "Year to Today" presets now correctly use todayDate instead of calendarEnd

7. Enhanced Year Selection Logic

  • Feature: Improved year selection to handle month boundaries when switching years
  • Implementation:
    • When changing years, attempts to keep the same month if valid
    • If the same month is invalid in the new year, finds the closest valid month
  • Impact: Smoother user experience when navigating between years with different available date ranges

Checklist

  • For UI or styling changes, I have added a screenshot or gif showing before & after
  • I have added a changeset
  • I have added to the docs where applicable
  • I have added to the VS Code extension where applicable

@arefabouhamdan arefabouhamdan had a problem deploying to Approval required to run action on external PR November 12, 2025 11:08 — with GitHub Actions Failure
@arefabouhamdan arefabouhamdan had a problem deploying to Approval required to run action on external PR November 12, 2025 11:37 — with GitHub Actions Failure
@arefabouhamdan arefabouhamdan had a problem deploying to Approval required to run action on external PR November 12, 2025 12:36 — with GitHub Actions Failure
@arefabouhamdan arefabouhamdan had a problem deploying to Approval required to run action on external PR November 12, 2025 12:39 — with GitHub Actions Failure
@arefabouhamdan arefabouhamdan marked this pull request as ready for review November 12, 2025 12:44
@hughess
Copy link
Member

hughess commented Nov 30, 2025

@arefabouhamdan it looks like the only check failing is the formatting/lint check. If you run npm run format and npm run lint and push the changes it should take care of it

@hughess
Copy link
Member

hughess commented Nov 30, 2025

@arefabouhamdan for the timezone and off-by-one issues, can you share how you were seeing that show up? We've typically only seen it with users east of UTC line, so just want to make sure you had a good starting test that was failing and can confirm it works now both in that case, and in the west of UTC case

@arefabouhamdan arefabouhamdan deployed to Approval required to run action on external PR December 1, 2025 15:35 — with GitHub Actions Active
@hughess
Copy link
Member

hughess commented Dec 2, 2025

@arefabouhamdan do you know why the default dates of the date input have changed? Below are current live docs and the preview docs from this PR:

Current Docs

CleanShot 2025-12-01 at 20 56 34@2x

This PR

CleanShot 2025-12-01 at 20 56 22@2x

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