DatePicker omits timezone for initially empty fields despite zoned placeholderValue

未关闭 适合新手
#10,900 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@mrlexcoder 已经在做这个了。

开始于 2026年11月3日。

  • #10911 来自 @mrlexcoder —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
react, typescript
领域
frontend

调研方向

相关代码是 placeholderValue,位于 DatePicker.tsx 中:它从 props 中解构出来,但没有传给 AriaDatePicker,只传到了弹出层中的 TimeField。请先阅读组件如何构建 props,然后运行链接的 StackBlitz 复现,确认提交的值不含时区。完成标准是:带时区的 placeholderValue 的空 DatePicker 提交的值包含 UTC 时区,且现有的 DatePicker 测试全部通过。

由索引模型根据 Issue 内容生成。

描述

bug
Provide a general summary of the issue here

An initially empty DatePicker with placeholderValue={now("UTC")} produces a date-time without a timezone after selecting a date.

🤔 Expected Behavior?

The selected value should inherit the UTC timezone from placeholderValue.

😯 Current Behavior

Selecting 2 November 2026 and submitting the form sends 2026-11-02T00:00:00. The value contains neither a timezone identifier nor an offset.

💁 Possible Solution

DatePicker.tsx destructures placeholderValue out of its props but does not forward it to <AriaDatePicker>. It only passes it to the popover’s TimeField.

🔦 Context

This affects a form containing date pickers. The backend expects zoned date-times for all submissions, so it rejects the submitted values.

🖥️ Steps to Reproduce

https://stackblitz.com/edit/e6rtt68y?file=src%2FExample.tsx

  1. Open the page
  2. Open the calendar popup and select a date
  3. Submit the form
  4. Observe the submitted value
Version

@react-spectrum/s2 1.8.2

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

主要语言
TypeScript
星标
16k
派生
1.6k
平均合并
3 天 9 小时
30 天内合并 PR
45

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

adobe/react-spectrum 的其他 Issue

查看 adobe/react-spectrum 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。