fix(date-panel): fix date selection off-by-one day when clicking dates( #4138)#4263
fix(date-panel): fix date selection off-by-one day when clicking dates( #4138)#4263Georgyhongbo wants to merge 1 commit into
Conversation
The modelValue watcher in date-panel incorrectly used getUTCDate() + 1 which caused a double timezone correction, resulting in the selected date being offset by one day. Changed to use getDate() which gives the correct local date value, consistent with how date-range and month-range components handle the same logic.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe date-panel ChangesDate normalization
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The modelValue watcher in date-panel incorrectly used
getUTCDate() + 1which caused a double timezone correction, resulting in the selected date being offset by one day. Changed to usegetDate()which gives the correct local date value, consistent with how date-range and month-range components handle the same logic.PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When clicking a date in the DatePanel component, the wrong date is selected. For example, clicking "15" first selects "16". A second click on "15" is required to correctly select it. The bug occurs because the modelValue watcher applies a double timezone correction (
val - localOffsetplusgetUTCDate() + 1), which shifts the date forward by one day.Issue Number: N/A
What is the new behavior?
Clicking any date in DatePanel selects the correct date immediately, with no off-by-one error.
Does this PR introduce a breaking change?
Other information
Only one line changed in
packages/renderless/src/date-panel/vue.ts. The fix aligns with howdate-rangeandmonth-rangealready handle the same logic usinggetDate()instead ofgetUTCDate() + 1.Summary by CodeRabbit