fix: align meridiem labels with 12-hour periods#974
Conversation
|
@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
概览TimePanelBody 将用于生成 AM/PM 上下午标签的示例日期中的小时值从 6/18 更改为 9/15,对应的测试断言也进行了更新。 变更Meridiem 标签时间调整
估计代码审查工作量🎯 1 (平凡) | ⏱️ ~3 分钟 建议审查者
诗
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/PickerPanel/TimePanel/TimePanelBody/index.tsxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. tests/new-range.spec.tsxESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. 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 |
There was a problem hiding this comment.
Code Review
This pull request updates the hour values used to generate AM and PM dates in the TimePanelBody component, changing AM from 6 to 9 and PM from 18 to 15. Additionally, the corresponding test assertions in new-range.spec.tsx have been updated to reflect the new Chinese localization strings ('上午' and '下午'). There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #974 +/- ##
=======================================
Coverage 98.81% 98.81%
=======================================
Files 65 65
Lines 2695 2695
Branches 724 724
=======================================
Hits 2663 2663
Misses 29 29
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/PickerPanel/TimePanel/TimePanelBody/index.tsx (1)
117-118: 💤 Low value建议添加注释说明小时值的选择理由。
为了提高代码的可维护性,建议添加简短注释解释为何选择 9 和 15 作为样本小时值。这有助于未来的维护者理解设计决策。
📝 建议的注释
const base = generateConfig.getNow(); + // Use 9:00 and 15:00 as sample times to ensure generic AM/PM labels + // (e.g., "上午"/"下午" in Chinese, avoiding time-specific variants like "早上"/"晚上") const amDate = generateConfig.setHour(base, 9); const pmDate = generateConfig.setHour(base, 15);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/PickerPanel/TimePanel/TimePanelBody/index.tsx` around lines 117 - 118, Add a short inline comment explaining why 9 and 15 were chosen for sample hours: update the lines that create amDate and pmDate (using generateConfig.setHour(base, 9) and generateConfig.setHour(base, 15)) to include a concise note about the decision (e.g., representing typical AM/PM midday samples or avoiding DST edge cases), so future maintainers understand the rationale.tests/new-range.spec.tsx (1)
333-341: ⚡ Quick win测试断言更新正确,建议考虑增加跨语言环境的测试覆盖。
测试期望值已正确更新为
'上午'和'下午',与源代码的更改保持一致。当前测试针对中文语言环境验证了修复效果。为了确保更改在所有支持的语言环境下都能正常工作,建议考虑添加针对其他语言环境(如英语、阿拉伯语等)的类似测试用例,验证小时 9 和 15 在这些语言环境下也能产生正确的 AM/PM 标签。
💡 示例:英语语言环境测试
it('cellMeridiemFormat should work for en_US', () => { render( <DayRangePicker picker="time" locale={{ ...en_US, cellMeridiemFormat: 'A', }} showTime={{ use12Hours: true, }} open />, ); expect( document.querySelectorAll('[data-type="meridiem"] .rc-picker-time-panel-cell')[0] .textContent, ).toEqual('AM'); expect( document.querySelectorAll('[data-type="meridiem"] .rc-picker-time-panel-cell')[1] .textContent, ).toEqual('PM'); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/new-range.spec.tsx` around lines 333 - 341, The test currently asserts Chinese meridiem labels ('上午'/'下午') in tests/new-range.spec.tsx for DayRangePicker; add parallel test cases that render DayRangePicker with alternate locales (e.g., en_US with cellMeridiemFormat: 'A' and an RTL or other locale) and showTime.use12Hours=true, then assert the meridiem cell texts are 'AM'/'PM' (and appropriate RTL labels) to ensure cross-language coverage; locate test block referencing '[data-type="meridiem"] .rc-picker-time-panel-cell' and duplicate with different locale props to validate outputs across languages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/PickerPanel/TimePanel/TimePanelBody/index.tsx`:
- Around line 117-118: Add a short inline comment explaining why 9 and 15 were
chosen for sample hours: update the lines that create amDate and pmDate (using
generateConfig.setHour(base, 9) and generateConfig.setHour(base, 15)) to include
a concise note about the decision (e.g., representing typical AM/PM midday
samples or avoiding DST edge cases), so future maintainers understand the
rationale.
In `@tests/new-range.spec.tsx`:
- Around line 333-341: The test currently asserts Chinese meridiem labels
('上午'/'下午') in tests/new-range.spec.tsx for DayRangePicker; add parallel test
cases that render DayRangePicker with alternate locales (e.g., en_US with
cellMeridiemFormat: 'A' and an RTL or other locale) and
showTime.use12Hours=true, then assert the meridiem cell texts are 'AM'/'PM' (and
appropriate RTL labels) to ensure cross-language coverage; locate test block
referencing '[data-type="meridiem"] .rc-picker-time-panel-cell' and duplicate
with different locale props to validate outputs across languages.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 04f1f28a-4534-4c92-b52e-b5efb4a552d9
📒 Files selected for processing (2)
src/PickerPanel/TimePanel/TimePanelBody/index.tsxtests/new-range.spec.tsx
Summary
cellMeridiemFormat: Arender generic上午/下午labels instead of早上/晚上Root Cause
The time panel used 6:00 and 18:00 as sample dates for formatting AM/PM labels. In Chinese locales those hours map to
早上and晚上, while selected values such as 13:00 format as下午, causing the panel label and input value to diverge.Testing
npm test -- tests/new-range.spec.tsx --runInBandnpm run lint:tscgit diff --checkRef: ant-design/ant-design#58286
Summary by CodeRabbit
发布说明
Bug 修复
测试