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

@@ -376,30 +376,34 @@ const handleKeydown = (e: KeyboardEvent, _open?: boolean, _isDatePicker = false)
}
}
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 || timePickerRef.value) && /^[0-9a-z]$/i.test(e.key)) {
isClearedInputMode.value = true
isDatePicker.value ? datePickerRef.value?.focus() : timePickerRef.value?.focus()
editable.value = true
open.value = true
}
})
if (!isOpen.value && (datePickerRef.value || timePickerRef.value) && /^[0-9a-z]$/i.test(e.key)) {
isClearedInputMode.value = true
isDatePicker.value ? datePickerRef.value?.focus() : timePickerRef.value?.focus()
editable.value = true
open.value = true
}
},
{
immediate: true,
isGridCell: isGrid.value,
},
)
watch(editable, (nextValue) => {
if (isGrid.value && nextValue && !open.value) {