-
Couldn't load subscription status.
- Fork 317
fix(DateTimePicker): 修复在 showWeek 模式下日列表未正确排除 start、end、且 steps 步长不生效的 Bug #3861
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
Conversation
commit: |
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.
Pull Request Overview
This PR fixes a bug in the DateTimePicker component where the day list in showWeek mode was not properly excluding dates outside the start and end range. When show-week was enabled with start="{{nowTime()}}", the day list showed dates before the start time that should have been filtered out.
- Added proper date range validation using
getMinDate()andgetMaxDate()methods - Modified the day generation logic to skip dates outside the allowed range
- Implemented early loop termination when reaching the maximum date
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
重构 getDaysOfWeekInMonth 方法,使用 getOptionEdge 获取边界值并支持步长配置,简化循环逻辑,移除不必要的日期范围检查
* fix(DateTimePicker): 修复在 showWeek 模式下日列表未正确排除 start、end、且 steps 步长不生效的 Bug (#3861) * fix(DateTimePicker): 修复在 showWeek 模式下日列表未正确排除 start 和 end 的 Bug * refactor(date-time-picker): 优化日期周显示逻辑,使用统一边界和步长控制 重构 getDaysOfWeekInMonth 方法,使用 getOptionEdge 获取边界值并支持步长配置,简化循环逻辑,移除不必要的日期范围检查 * refactor: use monorepo (#3660) * chore: directory structure optimization * chore: update coverage badges * chore: update dependency installation to use pnpm action * chore: the respective package.json * chore: move test to root dir * chore: update jest config * chore: update typos-config * chore: update typos-config * chore: update import path * chore: lint * chore: update script * chore: update plugin script * chore: update script * chore: update deps * chore: update dep * chore: support ty live host * chore: update live host * chore: update badge script data path * chore: update vscode setting and nest files --------- Co-authored-by: novlan1 <[email protected]> * chore: update group code path (#3880) * fix(Message): use the correct error theme icon (#3879) * fix(Message): use the correct error theme icon * test: update snapshots --------- Co-authored-by: novlan1 <[email protected]> * docs: add pkg.pr.new badge (#3882) * chore(Textarea): using pseudo-elements (#3878) Co-authored-by: novlan1 <[email protected]> * feat(SideBarItem): add default slot (#3875) Co-authored-by: novlan1 <[email protected]> * fix(image-viewer): 修复背景色错误问题 (#3881) * chore(docs): regenerate (#3887) * fix: fix component name error * chore(docs): regenerate * chore: update live url (#3886) --------- Co-authored-by: composable-tu <[email protected]> Co-authored-by: betavs <[email protected]> Co-authored-by: novlan1 <[email protected]> Co-authored-by: wū yāng <[email protected]> Co-authored-by: liweijie0812 <[email protected]>
* fix(DateTimePicker): 修复在 showWeek 模式下日列表未正确排除 start、end、且 steps 步长不生效的 Bug (#3861) * fix(DateTimePicker): 修复在 showWeek 模式下日列表未正确排除 start 和 end 的 Bug * refactor(date-time-picker): 优化日期周显示逻辑,使用统一边界和步长控制 重构 getDaysOfWeekInMonth 方法,使用 getOptionEdge 获取边界值并支持步长配置,简化循环逻辑,移除不必要的日期范围检查 * refactor: use monorepo (#3660) * chore: directory structure optimization * chore: update coverage badges * chore: update dependency installation to use pnpm action * chore: the respective package.json * chore: move test to root dir * chore: update jest config * chore: update typos-config * chore: update typos-config * chore: update import path * chore: lint * chore: update script * chore: update plugin script * chore: update script * chore: update deps * chore: update dep * chore: support ty live host * chore: update live host * chore: update badge script data path * chore: update vscode setting and nest files --------- Co-authored-by: novlan1 <[email protected]> * chore: update group code path (#3880) * fix(Message): use the correct error theme icon (#3879) * fix(Message): use the correct error theme icon * test: update snapshots --------- Co-authored-by: novlan1 <[email protected]> * docs: add pkg.pr.new badge (#3882) * chore(Textarea): using pseudo-elements (#3878) Co-authored-by: novlan1 <[email protected]> * feat(SideBarItem): add default slot (#3875) Co-authored-by: novlan1 <[email protected]> * fix(image-viewer): 修复背景色错误问题 (#3881) * chore(docs): regenerate (#3887) * fix: fix component name error * chore(docs): regenerate * chore: update live url (#3886) * chore: update packageManager to [email protected] (#3889) * revert live url (#3892) * chore: revert live url * chore: update live url and always be outer host * chore: revert live url * chore: add m2w.sh (#3893) * chore: add m2w.sh * chore: update liveUrl * chore: use pnpm add --------- Co-authored-by: composable-tu <[email protected]> Co-authored-by: betavs <[email protected]> Co-authored-by: novlan1 <[email protected]> Co-authored-by: wū yāng <[email protected]> Co-authored-by: liweijie0812 <[email protected]>
🤔 这个 PR 的性质是?
🔗 相关 Issue
fix #3860
当组件开启
show-week且start="{{nowTime()}}"时,「日」列表界面与未开启show-week的「日」列表界面不一致:show-week时「日」列显示了nowTime()之前的日期,关闭show-week后则消失。show-week时,steps 步长设置对「日」不生效,关闭则正常。💡 需求背景和解决方案
应该是在
getOptionByType(type: string)函数中,if (type === 'date' && showWeek)直接返回了getDaysOfWeekInMonth(this.date)的结果,忽视了start、end和steps值。tdesign-miniprogram/src/date-time-picker/date-time-picker.ts
Lines 104 to 121 in b3bdc82
我这里把上述函数代码改成以下代码就可以了:
📝 更新日志
showWeek模式下日(date)列表未正确排除start和end、且steps步长无效的问题☑️ 请求合并前的自查清单