naive-ui
naive-ui copied to clipboard
Date Picker中的shortcuts有点小问题
Describe the bug
如图,我点击"本月"按钮触发弹窗的消失动画,在动画过程中鼠标指针会划过"最近三年"按钮,导致选择的是本月,但显示的是最近三年.
Steps to reproduce
当快捷按钮有多列时,消失动画可能导致鼠标指针触碰其它按钮
Link to minimal reproduction
none
System Info
chrome
Used Package Manager
npm
Validations
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- [x] The provided reproduction is a minimal reproducible example of the bug.
Provide a based on Playground or CodeSandbox or stackblitz `s MinimalReproducible Example
遇到了同样的问题
目前我这边是通过覆盖原方法以解决此问题.
<NDatePicker ref={cmpRef} />
TS样例仅供参考:
const cmpRef = ref<{ panelInstRef?: { $el?: HTMLElement } } | null>(null)
const overrideFn = ref({
handleRangeShortcutMouseenter: undefined as ((shortcut: Shortcuts[string]) => void) | undefined
})
const pendingShortcutEnterEventFlagRef = ref(false)
watch(
() => cmpRef.value?.panelInstRef,
(newVal) => {
if (newVal && cmpRef.value && cmpRef.value.panelInstRef && cmpRef.value.panelInstRef.$el) {
pendingShortcutEnterEventFlagRef.value = true
const panelInst: JSONStruct = cmpRef.value.panelInstRef
overrideFn.value.handleRangeShortcutMouseenter = panelInst.handleRangeShortcutMouseenter
panelInst.handleRangeShortcutMouseenter = (shortcut: Shortcuts[string]) => {
if (!pendingShortcutEnterEventFlagRef.value) {
return
}
overrideFn.value.handleRangeShortcutMouseenter?.(shortcut)
}
panelInst.handleRangeShortcutClick = (shortcut: typeof Function) => {
pendingShortcutEnterEventFlagRef.value = false
const shortcutValue = panelInst.getShortcutValue(shortcut)
if (!Array.isArray(shortcutValue)) return
panelInst.changeStartEndTime(shortcutValue[0], shortcutValue[1], 'shortcutPreview') // 此处同时解决了另外一个问题 ['done' -> 'shortcutPreview' #6901]
panelInst.clearPendingValue()
panelInst.handleConfirmClick()
}
}
}
)
This issue does not have any recent activity. If you are still experiencing similar problems, open a new error, including a minimal copy of the problem