-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(TimePicker & DatePicker): fix the 'formatValueRange' function defect #13094
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13094 +/- ##
==========================================
- Coverage 89.66% 89.66% -0.01%
==========================================
Files 257 257
Lines 6987 6994 +7
Branches 1724 1726 +2
==========================================
+ Hits 6265 6271 +6
+ Misses 382 380 -2
- Partials 340 343 +3 ☔ View full report in Codecov by Sentry. |
相比起移除 issue 里提到的 export const formatValueRange = (
values: string[],
columns: PickerOption[][],
) => {
if (values.length === 0) {
return columns.map((column) => column[0]?.value?.toString() ?? ''); // 新增的兜底逻辑
}
return values.map((value, index) => {
const column = columns[index];
if (column.length) {
const minValue = +column[0].value!;
const maxValue = +column[column.length - 1].value!;
return padZero(clamp(+value, minValue, maxValue));
}
return value;
});
}; 当 v-model 入参为 undefined,内部的私有变量将启用默认值 [],当该私有变量为 [] 时,新增的兜底逻辑将生效,将该变量修改为每一列可选数据的第一项。 |
说实话,能修复这个 BUG 的地方似乎有点多。我其实一时分不清到底哪里才是真正应该修复的地方, 我没有将该 PR 为什么能解决问题解释的很清楚,因为它实在是不好解释。这可能需要先去仔细查看对应 issue 中的内容,然后仔细体验一下最小复现。 |
可以补充一下单元测试 |
单测已添加。但是单测只是单纯的验证了一下新增的逻辑是否生效,并没有去验证是否解决了 issue 中的 BUG,因为我没想到该如何编写这种复杂场景的单测 |
解决该 issue 中提到的第 1 个问题: #13084