-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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: 修复 calendar-picker-view 的一些问题 #6760
fix: 修复 calendar-picker-view 的一些问题 #6760
Conversation
yuanjiu041
commented
Oct 14, 2024
- 修复了默认的 minDay 和 maxDay 会随着 current 变化的问题 CalendarPickerView 相关的一些问题 #6759
- 修复了 view 打开时不会自动滚动到选中值的问题 CalendarPickerView 相关的一些问题 #6759
const maxDay = useMemo( | ||
() => (props.max ? dayjs(props.max) : current.add(6, 'month')), | ||
[props.max, current] | ||
() => (props.max ? dayjs(props.max) : defaultMin.add(6, 'month')), |
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.
Test case?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6760 +/- ##
==========================================
+ Coverage 92.68% 92.74% +0.05%
==========================================
Files 334 334
Lines 7191 7204 +13
Branches 1795 1763 -32
==========================================
+ Hits 6665 6681 +16
+ Misses 517 515 -2
+ Partials 9 8 -1 ☔ View full report in Codecov by Sentry. |
@@ -124,20 +128,23 @@ export const CalendarPickerView = forwardRef< | |||
const scrollTo = useSyncScroll(current, context.visible, bodyRef) | |||
|
|||
// ============================== Boundary ============================== | |||
// 记录默认的 current,防止后续 current 更新影响到下面的 minDay 和 maxDay 的计算 | |||
const defaultMin = useMemo(() => current, []) |
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.
这个有点怪,如果不设置 min
的时候,defaultMin
锁死是当前日期。至少也是这个月的开始才对?如果留有余量的话,应该是范围默认正负半年比较好
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.
历史设计就是当前,他会取到这个月的第一天
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.
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.
OK,那如果 current 受控小于当前日期呢?是不是需要刷新一下~
) | ||
|
||
// ================================ Refs ================================ | ||
useImperativeHandle(ref, () => ({ | ||
jumpTo: pageOrPageGenerator => { | ||
let page: Page | ||
if (typeof pageOrPageGenerator === 'function') { | ||
console.log('cccc: ', current) |
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.
console 没删
- 修复了默认的 minDay 和 maxDay 会随着 current 变化的问题 - 修复了 view 打开时不会自动滚动到选中值的问题
263deae
to
713da41
Compare