-
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
feat: calendar picker view scroll #6521
base: master
Are you sure you want to change the base?
feat: calendar picker view scroll #6521
Conversation
@zombieJ 这块这样实现可行吗,可行的话我添加文档和修复用例报错 |
<div | ||
className={classNames( | ||
`${classPrefix}-cell-date`, | ||
`${classPrefix}-cell-${d.format('YYYY-MM-DD')}` |
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.
不要加到 className 里,可以加个 data-date
。
PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6521.surge.sh |
@zombieJ 帮忙review一下呢 |
感觉这个 api 有点奇怪。是不是打开弹窗之后最好可以直接定位到选择的日期,而不是再调用个 api 来滚动到相应的位置? |
弹窗打开的时候内部调用了这个api 不需要再手动调用了 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6521 +/- ##
==========================================
+ Coverage 92.27% 92.29% +0.02%
==========================================
Files 316 316
Lines 6897 6906 +9
Branches 1728 1733 +5
==========================================
+ Hits 6364 6374 +10
+ Misses 497 496 -1
Partials 36 36 ☔ View full report in Codecov by Sentry. |
@bravepg,印象里渲染面板数量有限。这个 scrollTo 感觉容易超出范围经常不生效。确认一下。 |
@@ -73,7 +73,12 @@ export const CalendarPicker = forwardRef< | |||
getContainer, | |||
...calendarViewProps | |||
} = props | |||
|
|||
useEffect(() => { |
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.
useEffect(() => {
setImmediate(() => {
const dateRange = calendarRef.current?.getDateRange() ?? null
if (dateRange && dateRange[0]) {
calendarRef.current?.scrollTo(dateRange[0])
}
})
}, [visible])
加setImmediate, 当 visible 为 true 时,calendarRef.current不能立刻取到
🤡我当时没想这么多 |
测试有两个未通过,不太清楚为什么。