-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
disableDate后导致部分日期无法禁用或无法点击 #188
Conversation
1.Cannot select Year or Month when disabled the date. 2.The choice decade presents the problem of showing the wrong decade
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/react-component/picker/kx1f4skop |
Codecov Report
@@ Coverage Diff @@
## master #188 +/- ##
=======================================
Coverage 99.60% 99.60%
=======================================
Files 45 45
Lines 2033 2045 +12
Branches 600 599 -1
=======================================
+ Hits 2025 2037 +12
Misses 6 6
Partials 2 2
Continue to review full report at Codecov.
|
此外 ant-design #26697也是这样的问题 |
@@ -62,6 +63,8 @@ const generateConfig: GenerateConfig<Date> = { | |||
setHour: (date, hour) => setHours(date, hour), | |||
setMinute: (date, minute) => setMinutes(date, minute), | |||
setSecond: (date, second) => setSeconds(date, second), | |||
addEndMonth: (date, diff) => addMonths(endOfMonth(date), diff), | |||
addEndYear: (date, diff) => addYears(endOfYear(date), diff), |
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.
这个里面的方法都是到时暴露给用户的,但是在这里只是供内部使用,不够优雅。
我认为这个应该是判断禁用时的边界问题,看看能不能通过内部写个自定义的hook什么的专门判断月份、年等面板的禁用日期?
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.
在判断月份和年等面板的时候是用户的disableDate
函数返回,这个函数内部对比是无法感知的而且是基于moment
等外部库的比较,如果用内部的自定义方法去干涉disableDate
函数内部的比较可能会导致antd暴露的api产生变动。
关于generate
里的方法似乎只是内部使用,我并未找到暴露的接口😂
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.
没事😅,其他能帮忙review一下吗
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.
你这个解决方案是将调用 disableDate
函数的日期参数改为了,月、年、十年的末尾日期去比较,这样的确解决了 issue 里面的问题,但是应该没有从根源解决。
issue 中 disableDate 的逻辑是禁用今天与今天之前的日期,用你这种方法是可行的,但是如果 disableDate 禁用的是今天和今天之后的日期,这是切换到月份面板的时候,按照你的方法,当前的月份还是会被禁用的,还有更复杂的,当禁用这个月中的某个区间的时候(例如今天19号,禁用15号到20号),你的方法还是不适用的。
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.
感觉只有重写disable逻辑才能解决问题了,因为这一步是将内部的函数暴露给用户,用户的逻辑代码无法获取
我重写了 disabledDate 的逻辑,可以去这里看看,帮忙测测有什么问题:#191 |
这个我就先关了,所有问题可以在那边讨论,到时提交的时候,作者我会把你加上的。 |
好的,谢谢带佬😘 |
1、禁用日期后decade无法禁用
具体例子见
ant-design #28155
2、在disableDate今日日期后选择’年份‘或’月份‘无法返回
在ant-design #28155中我发现了新问题,在禁用当年的时间后点击年或月无法返回
更新日志