Skip to content

Commit 6ecd529

Browse files
uyarnCopilottdesign-bot
authored
fix(DatePicker): fix error when replacing close button (#6108)
* fix(datepicker): fix error when replace close btn * chore: optimize desc * chore: optimize Co-authored-by: Copilot <[email protected]> * chore: stash changelog [ci skip] --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: tdesign-bot <[email protected]>
1 parent 3016325 commit 6ecd529

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/components/date-picker/hooks/useRange.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ export function useRange(props: TdDateRangePickerProps) {
5858
onClick: ({ position }: any) => {
5959
activeIndex.value = position === 'first' ? 0 : 1;
6060
},
61-
onClear: ({ e }: { e: MouseEvent }) => {
62-
e.stopPropagation();
61+
onClear: (context: { e: MouseEvent } | MouseEvent) => {
62+
// 处理全局替换关闭图标的场景,此时 event 可能不在 context 里面,而是 context 本身
63+
if (context instanceof MouseEvent) context.stopPropagation();
64+
else context.e.stopPropagation();
65+
6366
popupVisible.value = false;
6467
onChange?.([], { dayjsValue: [], trigger: 'clear' });
6568
},
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
pr_number: 6108
3+
contributor: uyarn
4+
---
5+
6+
- fix(DateRangePicker): 修复全局替换图标场景下,点击关闭按钮报错的问题 @uyarn ([#6108](https://github.com/Tencent/tdesign-vue-next/pull/6108))

0 commit comments

Comments
 (0)