From 79db37c176ddbaf1615388b2b401ffbc3ac07d91 Mon Sep 17 00:00:00 2001 From: Zhang sile <820774459@qq.com> Date: Fri, 14 Nov 2025 16:16:30 +0800 Subject: [PATCH 1/8] =?UTF-8?q?fix(date-picker):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E9=80=89=E6=8B=A9=E5=99=A8=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=AF=AF=E8=A7=A6=E5=8F=91=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.en-US.md | 1 + CHANGELOG.zh-CN.md | 1 + src/date-picker/src/panel/use-calendar.ts | 7 ++++++- src/date-picker/src/panel/use-dual-calendar.ts | 7 ++++++- src/date-picker/src/panel/use-panel-common.ts | 16 ++++++++++++++-- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index f67b6c48486..b5d426057c7 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -7,6 +7,7 @@ - Fix seemly dependency version range allows incompatible versions. - Fix `n-progress` style is incorrect after using the dashboard mode exceeding 100%, closes [#6627](https://github.com/tusen-ai/naive-ui/issues/6627) - Fix `n-modal`'s outside content can't be interacted with `show-mask` is set to `false`. +- Fix `n-date-picker`'s shortcut button misfires the click event, closes [#7315](https://github.com/tusen-ai/naive-ui/issues/7315) ### Feats diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 2d9976d2a57..4159312b20f 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -7,6 +7,7 @@ - 修复 seemly 依赖的版本未更新到最新 - 修复 `n-progress` 使用仪表盘模式超过 100% 之后样式不正确,关闭 [#6627](https://github.com/tusen-ai/naive-ui/issues/6627) - 修复 `n-modal` 在 `show-mask` 为 `false` 的情况下,外部内容不能被操作 +- 修复 `n-date-picker` 的快捷按钮在点击后误触发的问题,关闭 [#7315](https://github.com/tusen-ai/naive-ui/issues/7315) ### Feats diff --git a/src/date-picker/src/panel/use-calendar.ts b/src/date-picker/src/panel/use-calendar.ts index 3873180a909..738d928983b 100644 --- a/src/date-picker/src/panel/use-calendar.ts +++ b/src/date-picker/src/panel/use-calendar.ts @@ -506,6 +506,8 @@ function useCalendar( panelCommon.doUpdateValue(value, props.panel) } function handleSingleShortcutMouseenter(shortcut: Shortcuts[string]): void { + if (panelCommon.isShortcutClickInProgressRef.value) + return panelCommon.cachePendingValue() const shortcutValue = panelCommon.getShortcutValue(shortcut) if (typeof shortcutValue !== 'number') @@ -513,9 +515,12 @@ function useCalendar( panelCommon.doUpdateValue(shortcutValue, false) } function handleSingleShortcutClick(shortcut: Shortcuts[string]): void { + panelCommon.isShortcutClickInProgressRef.value = true const shortcutValue = panelCommon.getShortcutValue(shortcut) - if (typeof shortcutValue !== 'number') + if (typeof shortcutValue !== 'number') { + panelCommon.isShortcutClickInProgressRef.value = false return + } panelCommon.doUpdateValue(shortcutValue, props.panel) panelCommon.clearPendingValue() handleConfirmClick() diff --git a/src/date-picker/src/panel/use-dual-calendar.ts b/src/date-picker/src/panel/use-dual-calendar.ts index eba2c349806..5983c0c50f1 100644 --- a/src/date-picker/src/panel/use-dual-calendar.ts +++ b/src/date-picker/src/panel/use-dual-calendar.ts @@ -733,6 +733,8 @@ function useDualCalendar( changeEndDateTime(value) } function handleRangeShortcutMouseenter(shortcut: Shortcuts[string]): void { + if (panelCommon.isShortcutClickInProgressRef.value) + return panelCommon.cachePendingValue() const shortcutValue = panelCommon.getShortcutValue(shortcut) if (!Array.isArray(shortcutValue)) @@ -740,9 +742,12 @@ function useDualCalendar( changeStartEndTime(shortcutValue[0], shortcutValue[1], 'shortcutPreview') } function handleRangeShortcutClick(shortcut: Shortcuts[string]): void { + panelCommon.isShortcutClickInProgressRef.value = true const shortcutValue = panelCommon.getShortcutValue(shortcut) - if (!Array.isArray(shortcutValue)) + if (!Array.isArray(shortcutValue)) { + panelCommon.isShortcutClickInProgressRef.value = false return + } changeStartEndTime(shortcutValue[0], shortcutValue[1], 'shortcutDone') panelCommon.clearPendingValue() handleConfirmClick() diff --git a/src/date-picker/src/panel/use-panel-common.ts b/src/date-picker/src/panel/use-panel-common.ts index 32103b1775e..422977c2c33 100644 --- a/src/date-picker/src/panel/use-panel-common.ts +++ b/src/date-picker/src/panel/use-panel-common.ts @@ -8,7 +8,7 @@ import type { Value } from '../interface' import { useKeyboard } from 'vooks' -import { computed, inject, nextTick, ref } from 'vue' +import { computed, inject, nextTick, ref, watch } from 'vue' import { datePickerInjectionKey } from '../interface' const TIME_FORMAT = 'HH:mm:ss' @@ -165,6 +165,17 @@ function usePanelCommon(props: UsePanelCommonProps) { function handleOpenQuickSelectMonthPanel(): void { showMonthYearPanel.value = !showMonthYearPanel.value } + + const isShortcutClickInProgressRef = ref(false) + watch( + () => props.active, + (show) => { + if (!show) { + isShortcutClickInProgressRef.value = false + } + } + ) + return { mergedTheme: mergedThemeRef, mergedClsPrefix: mergedClsPrefixRef, @@ -188,7 +199,8 @@ function usePanelCommon(props: UsePanelCommonProps) { getShortcutValue, handleShortcutMouseleave: restorePendingValue, showMonthYearPanel, - handleOpenQuickSelectMonthPanel + handleOpenQuickSelectMonthPanel, + isShortcutClickInProgressRef } } From bf6cf0435cde42830f7fb9581fa9e098b48cb223 Mon Sep 17 00:00:00 2001 From: kvii <56432636+kvii@users.noreply.github.com> Date: Tue, 21 Oct 2025 22:52:30 +0800 Subject: [PATCH 2/8] doc: typo (#7280) --- src/button/demos/zhCN/popover.demo.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/button/demos/zhCN/popover.demo.vue b/src/button/demos/zhCN/popover.demo.vue index 03c2b2c1ff7..33010b64264 100644 --- a/src/button/demos/zhCN/popover.demo.vue +++ b/src/button/demos/zhCN/popover.demo.vue @@ -1,7 +1,7 @@ # 配合 Popover 的特殊情况 -原生的 disabled 的 button 不会触发鼠标,因此 `n-popover` 无法监听到相关的事件。如果你需要在这种情况下使用,可以使用 `tag` 属性来调整 button 的行为。 +disabled 的原生 button 不会触发部分鼠标事件,因此 `n-popover` 无法监听到相关的事件。如果你需要在这种情况下使用,可以使用 `tag` 属性来调整 button 的行为。