Repository navigation
Conversation
| }; | ||
| }, | ||
|
|
||
| onInput(event) { |
There was a problem hiding this comment.
已移除。本 PR 现在只包含 packages/components/calendar/calendar.ts 与 packages/components/calendar/__test__/index.test.js 两个文件,textarea 的改动已从分支中剔除,不再出现在 diff 里。
| @@ -0,0 +1,49 @@ | |||
| import path from 'path'; | |||
There was a problem hiding this comment.
建议 scrollIntoView 场景的测试合到组件自己的测试文件中,不新建文件。(只保留父组件、子组件、工具函数单的单元测试文件)
There was a problem hiding this comment.
已按建议合并。scrollIntoView 场景的用例已并入 packages/components/calendar/__test__/index.test.js,scroll-into-view.test.js 已删除(见 8a1689c)。
30a39aa to
278043b
Compare
|
已按 review 意见调整:
现在改动范围: 本地验证: |
calcMonths returned early for switchMode 'none' after setting months only, so currentMonth stayed at its initial empty object. Opening the panel could not locate the selected range whenever minDate/maxDate spanned a long period. Derive currentMonth in that branch too, keeping the existing behaviour of not touching the month switch buttons. fix Tencent#4718
Review feedback: keep one unit test file per component instead of adding a new file per scenario. The scrollIntoView case now lives in index.test.js under its own describe block, and scroll-into-view.test.js is gone. No behaviour change.
278043b to
8a1689c
Compare
Keep a single unit test file per component, as requested in the review of Tencent#4720: only parent, child and utility modules get their own files. Refs Tencent#4732.
🤔 这个 PR 的性质是?
🔗 相关 Issue
close #4718
💡 需求背景和解决方案
问题
issue #4718:区间模式下,
minDate与maxDate跨度很大时(例:2016-11 ~ 2026-12,共 122 个月),打开面板无法定位到选中的日期区间。复现参数:
根因
calcMonths在switchMode === 'none'(默认值)时提前返回,只设置months,不设置currentMonth:而
currentMonth的初始值是空对象{}(calendar.ts的data)。面板定位、区间高亮都依赖它,于是:跨度小时不容易察觉,因为默认落在相邻月份;跨度大时就会明显停在错误位置。
修改
switchMode === 'none'分支同样推导currentMonth,只是不动月份切换按钮(updateActionButton保持不调用,因为该模式下按钮不展示):验证
新增
packages/components/calendar/__test__/scroll-into-view.test.js:用 issue 给的实际参数(跨度 122 个月),visible从false切到true,断言:currentMonth[0]是{ year: 2022, month: 11 };scrollIntoView是year_2022_month_11;start.day === 5、end.day === 10。反向验证:还原
calendar.ts后跑:应用修复后 calendar 全量 16 passed(3 个测试文件)。
fix #4718
📝 更新日志
tdesign-miniprogram
☑️ 请求合并前的自查清单