fix(DatePicker): fix date-picker presets slot usage#6490
fix(DatePicker): fix date-picker presets slot usage#6490ZTH520 wants to merge 8 commits intoTencent:developfrom
Conversation
TDesign Component Site Preview Open
|
commit: |
There was a problem hiding this comment.
Pull request overview
Fixes DatePicker/DateRangePicker “presets” slot passthrough so that custom preset content can be rendered through panel/extra/footer layers.
Changes:
- Forward
presetsslot throughDatePicker/DateRangePicker→*Panel→ExtraContent→Footer - Update
ExtraContentfooter-visibility logic to considerpresetsslot - Refine
Footerrendering so presets container is only rendered when content exists
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/date-picker/components/panel/SinglePanel.tsx | Forwards presets slot into TExtraContent in both placement branches |
| packages/components/date-picker/components/panel/RangePanel.tsx | Forwards presets slot into TExtraContent in both placement branches |
| packages/components/date-picker/components/panel/ExtraContent.tsx | Uses slots.presets to decide footer visibility; forwards slot to footer |
| packages/components/date-picker/components/base/Footer.tsx | Renames component; makes presets wrapper conditional and normalizes slot rendering |
| packages/components/date-picker/_example/date-presets-alt.vue | Adds demos for presets prop and presets slot + preset-click handler |
| packages/components/date-picker/DateRangePicker.tsx | Forwards presets slot into TRangePanel when rendering popup panel |
| packages/components/date-picker/DatePicker.tsx | Forwards presets slot into TSinglePanel; adds onPresetClick callback invocation on preset apply |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| return ( | ||
| <div class={footerClass.value}> | ||
| {presetsContent ? <div class={presetsClass.value}>{presetsContent}</div> : null} |
There was a problem hiding this comment.
Pull request overview
This PR enhances the DatePicker/DateRangePicker preset customization pipeline by forwarding the presets slot through the popup panel hierarchy and aligning single-date preset behavior with range-picker by emitting preset-click from the internal preset handler.
Changes:
- Forward
#presetsslot fromDatePicker/DateRangePickerinto the underlying panel/footer components. - Emit
props.onPresetClickfor single-date preset selection (to match DateRangePicker behavior). - Refine footer rendering to avoid rendering an empty presets container when no presets content exists, and update the presets example.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/date-picker/DateRangePicker.tsx | Forwards presets slot to TRangePanel from the popup. |
| packages/components/date-picker/DatePicker.tsx | Forwards presets slot to TSinglePanel and emits onPresetClick on preset selection. |
| packages/components/date-picker/components/panel/SinglePanel.tsx | Passes presets slot down to TExtraContent (conditional). |
| packages/components/date-picker/components/panel/RangePanel.tsx | Passes presets slot down to TExtraContent. |
| packages/components/date-picker/components/panel/ExtraContent.tsx | Shows footer when presets slot exists; forwards slot to footer. |
| packages/components/date-picker/components/base/Footer.tsx | Renames component and conditionally renders presets container only when content exists. |
| packages/components/date-picker/_example/date-presets-alt.vue | Adds examples for presets prop/slot and preset-click usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -385,6 +386,7 @@ export default defineComponent({ | |||
| format: formatRef.value.format, | |||
| }); | |||
| popupVisible.value = false; | |||
| props.onPresetClick?.(context); | |||
| } | |||
| popupProps={popupProps.value} | ||
| rangeInputProps={rangeInputProps.value} | ||
| popupVisible={popupVisible.value} | ||
| panel={() => <TRangePanel {...panelProps.value} />} | ||
| panel={() => <TRangePanel {...panelProps.value} v-slots={{ presets: slots.presets }} />} | ||
| /> |

🤔 这个 PR 的性质是?
🔗 相关 Issue
#6487
💡 需求背景和解决方案
透传 presets
📝 更新日志
tdesign-vue-next
presets插槽用法无效,onPresetClick事件未正确触发的问题@tdesign-vue-next/chat
@tdesign-vue-next/auto-import-resolver
☑️ 请求合并前的自查清单