-
Notifications
You must be signed in to change notification settings - Fork 258
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: 日历滚动的时候 最后一个月日历副标题不准确 #2486
base: next
Are you sure you want to change the base?
Conversation
Walkthrough此次变更主要增强了 Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #2486 +/- ##
==========================================
+ Coverage 86.06% 86.12% +0.06%
==========================================
Files 217 217
Lines 22859 22850 -9
Branches 2549 2552 +3
==========================================
+ Hits 19673 19680 +7
+ Misses 3181 3165 -16
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
let HEIGHT_ITEM = 60 // 一行日历的高度 | ||
const LAST_MONTN_HAS_SIX_LINE = lastItem.monthData.length > 35 | ||
if (popup && autoBackfill) { | ||
HEIGHT_ITEM = LAST_MONTN_HAS_SIX_LINE ? 60 : 80 | ||
} else if (popup && !autoBackfill) { | ||
// 在popup里展示 且底部有确认按钮 | ||
HEIGHT_ITEM = LAST_MONTN_HAS_SIX_LINE ? 0 : 60 | ||
} else { | ||
HEIGHT_ITEM = LAST_MONTN_HAS_SIX_LINE ? 120 : 140 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的高度调整逻辑添加测试
新的高度调整逻辑缺乏测试覆盖。建议为以下情况添加测试:
popup
和autoBackfill
都为真。- 仅
popup
为真。 popup
和autoBackfill
都为假。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
Tools
GitHub Check: codecov/patch
[warning] 453-453: src/packages/calendaritem/calendaritem.tsx#L453
Added line #L453 was not covered by tests
[warning] 458-459: src/packages/calendaritem/calendaritem.tsx#L458-L459
Added lines #L458 - L459 were not covered by tests
// 让整个日历区域变高 确保能滚动到最后一个日历 | ||
const containerHeight = | ||
lastItem.cssHeight + lastItem.scrollTop + HEIGHT_ITEM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的容器高度计算逻辑添加测试
新的容器高度计算逻辑缺乏测试覆盖。建议为以下情况添加测试:
popup
和autoBackfill
都为真。- 仅
popup
为真。 popup
和autoBackfill
都为假。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
// avgHeight变小 确保current能取到最后一个月的索引 | ||
const current = Math.floor(scrollTop / avgHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的滚动位置逻辑添加测试
新的滚动位置逻辑缺乏测试覆盖。建议为以下情况添加测试:
- 滚动到最后一个月。
- 滚动到中间月份。
- 滚动到第一个月。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
Tools
GitHub Check: codecov/patch
[warning] 545-546: src/packages/calendaritem/calendaritem.tsx#L545-L546
Added lines #L545 - L546 were not covered by tests
if (current === monthsData.length - 1) { | ||
setDefaultRange(monthsNum, current) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的默认范围更新逻辑添加测试
新的默认范围更新逻辑缺乏测试覆盖。建议为以下情况添加测试:
- 滚动到最后一个月。
- 滚动到中间月份。
- 滚动到第一个月。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
Tools
GitHub Check: codecov/patch
[warning] 548-550: src/packages/calendaritem/calendaritem.tsx#L548-L550
Added lines #L548 - L550 were not covered by tests
let HEIGHT_ITEM = 60 // 一行日历的高度 | ||
const LAST_MONTN_HAS_SIX_LINE = lastItem.monthData.length > 35 | ||
if (popup && autoBackfill) { | ||
HEIGHT_ITEM = LAST_MONTN_HAS_SIX_LINE ? 60 : 80 | ||
} else if (popup && !autoBackfill) { | ||
// 在popup里展示 且底部有确认按钮 | ||
HEIGHT_ITEM = LAST_MONTN_HAS_SIX_LINE ? 0 : 60 | ||
} else { | ||
HEIGHT_ITEM = LAST_MONTN_HAS_SIX_LINE ? 120 : 140 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的高度调整逻辑添加测试
新的高度调整逻辑缺乏测试覆盖。建议为以下情况添加测试:
popup
和autoBackfill
都为真。- 仅
popup
为真。 popup
和autoBackfill
都为假。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
// 让整个日历区域变高 确保能滚动到最后一个日历 | ||
const containerHeight = | ||
lastItem.cssHeight + lastItem.scrollTop + HEIGHT_ITEM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的容器高度计算逻辑添加测试
新的容器高度计算逻辑缺乏测试覆盖。建议为以下情况添加测试:
popup
和autoBackfill
都为真。- 仅
popup
为真。 popup
和autoBackfill
都为假。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
// avgHeight变小 确保current能取到最后一个月的索引 | ||
const current = Math.floor(scrollTop / avgHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的滚动位置逻辑添加测试
新的滚动位置逻辑缺乏测试覆盖。建议为以下情况添加测试:
- 滚动到最后一个月。
- 滚动到中间月份。
- 滚动到第一个月。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
const current = Math.floor(scrollTop / avgHeight) | ||
if (current < 0) return | ||
if (!monthsData[current + 1]) return | ||
const nextTop = monthsData[current + 1].scrollTop | ||
const nextHeight = monthsData[current + 1].cssHeight | ||
if (current === 0) { | ||
if (scrollTop >= nextTop) { | ||
current += 1 | ||
} | ||
} else if (current > 0 && current < monthsNum - 1) { | ||
if (scrollTop >= nextTop) { | ||
current += 1 | ||
} | ||
if (scrollTop < monthsData[current].scrollTop) { | ||
current -= 1 | ||
} | ||
} else { | ||
const viewPosition = Math.round(scrollTop + viewHeight) | ||
if (current + 1 <= monthsNum && viewPosition >= nextTop + nextHeight) { | ||
current += 1 | ||
} | ||
if (current >= 1 && scrollTop < monthsData[current - 1].scrollTop) { | ||
current -= 1 | ||
} | ||
if (current === monthsData.length - 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议:为新的默认范围更新逻辑添加测试
新的默认范围更新逻辑缺乏测试覆盖。建议为以下情况添加测试:
- 滚动到最后一个月。
- 滚动到中间月份。
- 滚动到第一个月。
是否需要我为这些情况生成测试代码或创建 GitHub issue 来跟踪此任务?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有一个问题需要考虑,定高后,怎么灵活配置高度?
🤔 这个变动的性质是?
🔗 相关 Issue
#2384
💡 需求背景和解决方案
具体问题:将日历滚动到最后一个月份,上面的副标题展示的日期不是最后一个月的日期
实现方案:
根据以下情况给日历的容器增加高度 使得能滚动到最后一个月
1.在popup里展示+底部按钮
2.在popup里展示+无底部按钮
3.平铺展示
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
错误修复