Skip to content

fix(DatePicker): fix date-picker presets slot usage#6490

Open
ZTH520 wants to merge 8 commits intoTencent:developfrom
ZTH520:fix/date-picker-presets
Open

fix(DatePicker): fix date-picker presets slot usage#6490
ZTH520 wants to merge 8 commits intoTencent:developfrom
ZTH520:fix/date-picker-presets

Conversation

@ZTH520
Copy link
Contributor

@ZTH520 ZTH520 commented Mar 12, 2026

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

#6487

💡 需求背景和解决方案

透传 presets

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-vue-next

  • fix(DatePicker): 修复 presets 插槽用法无效,onPresetClick事件未正确触发的问题

@tdesign-vue-next/chat

@tdesign-vue-next/auto-import-resolver

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@tdesign-bot
Copy link
Collaborator

tdesign-bot commented Mar 12, 2026

TDesign Component Site Preview Open

Component Preview
tdesign-vue-next 完成
@tdesign-vue-next/chat 完成

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 12, 2026

  • tdesign-vue-next-demo

    npm i https://pkg.pr.new/@tdesign-vue-next/auto-import-resolver@6490
    
    npm i https://pkg.pr.new/tdesign-vue-next@6490
    
    npm i https://pkg.pr.new/@tdesign-vue-next/chat@6490
    

commit: af17261

@uyarn uyarn changed the title fix: 修复 date-picker presets 插槽支持 fix(DatePicker): fix date-picker presets slot usage Mar 12, 2026
@uyarn uyarn requested a review from Copilot March 13, 2026 06:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes DatePicker/DateRangePicker “presets” slot passthrough so that custom preset content can be rendered through panel/extra/footer layers.

Changes:

  • Forward presets slot through DatePicker/DateRangePicker*PanelExtraContentFooter
  • Update ExtraContent footer-visibility logic to consider presets slot
  • Refine Footer rendering 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.

Comment on lines +46 to +48
return (
<div class={footerClass.value}>
{presetsContent ? <div class={presetsClass.value}>{presetsContent}</div> : null}
Copy link
Contributor

Copilot AI left a 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 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 #presets slot from DatePicker / DateRangePicker into the underlying panel/footer components.
  • Emit props.onPresetClick for 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.

Comment on lines 371 to 390
@@ -385,6 +386,7 @@ export default defineComponent({
format: formatRef.value.format,
});
popupVisible.value = false;
props.onPresetClick?.(context);
}
Comment on lines 552 to 556
popupProps={popupProps.value}
rangeInputProps={rangeInputProps.value}
popupVisible={popupVisible.value}
panel={() => <TRangePanel {...panelProps.value} />}
panel={() => <TRangePanel {...panelProps.value} v-slots={{ presets: slots.presets }} />}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants