fix(nc-gui): use useSelectedCellKeyupListener instead useEventListener in date time related cell

This commit is contained in:
Ramesh Mane
2025-01-28 13:18:33 +00:00
parent 39e6f9b832
commit 8a39887c8c
3 changed files with 78 additions and 66 deletions

View File

@@ -275,30 +275,34 @@ const handleKeydown = (e: KeyboardEvent, _open?: boolean) => {
}
}
useEventListener(document, 'keydown', (e: KeyboardEvent) => {
// To prevent event listener on non active cell
if (!active.value) return
useSelectedCellKeyupListener(
active,
(e) => {
if (e.altKey || e.shiftKey) {
return
}
if (e.altKey || e.shiftKey || !isGrid.value || isExpandedForm.value || isEditColumn.value || isExpandedFormOpenExist()) {
return
}
if (e.metaKey || e.ctrlKey) {
if (e.key === ';') {
if (isGrid.value && !isExpandedForm.value && !isEditColumn.value) {
localState.value = dayjs(new Date())
e.preventDefault()
}
} else return
}
if (e.metaKey || e.ctrlKey) {
if (e.key === ';') {
if (isGrid.value && !isExpandedForm.value && !isEditColumn.value) {
localState.value = dayjs(new Date())
e.preventDefault()
}
} else return
}
if (!isOpen.value && datePickerRef.value && /^[0-9a-z]$/i.test(e.key)) {
isClearedInputMode.value = true
datePickerRef.value.focus()
editable.value = true
open.value = true
}
})
if (!isOpen.value && datePickerRef.value && /^[0-9a-z]$/i.test(e.key)) {
isClearedInputMode.value = true
datePickerRef.value.focus()
editable.value = true
open.value = true
}
},
{
immediate: true,
isGridCell: isGrid.value,
},
)
function handleSelectDate(value?: dayjs.Dayjs) {
tempDate.value = value