Browse Source

feat: shift+tab on first row, col change page to previous page

pull/7608/head
Ramesh Mane 11 months ago
parent
commit
64bd0d7c11
  1. 47
      packages/nc-gui/components/smartsheet/grid/Table.vue

47
packages/nc-gui/components/smartsheet/grid/Table.vue

@ -602,57 +602,72 @@ const {
return true return true
} }
} else if (e.key === 'Tab') { } else if (e.key === 'Tab') {
if (activeCell.row === dataRef.value.length - 1 && activeCell.col === fields.value?.length - 1) { if (e.shiftKey && activeCell.row === 0 && activeCell.col === 0 && !paginationDataRef.value?.isFirstPage) {
e.preventDefault() e.preventDefault()
editEnabled.value = false editEnabled.value = false
resetSelectedRange()
await changePage?.(paginationDataRef.value?.page! - 1)
await nextTick()
makeActive((paginationDataRef.value?.pageSize ?? 25) - 1, fields.value?.length - 1)
return true
} else if (!e.shiftKey && activeCell.row === dataRef.value.length - 1 && activeCell.col === fields.value?.length - 1) {
e.preventDefault()
if (paginationDataRef.value?.isLastPage && isAddingEmptyRowAllowed.value) { if (paginationDataRef.value?.isLastPage && isAddingEmptyRowAllowed.value) {
addEmptyRow() addEmptyRow()
activeCell.row = dataRef.value.length - 1
activeCell.col = 0
resetSelectedRange() resetSelectedRange()
await nextTick() await nextTick()
makeActive(dataRef.value.length - 1, 0)
;(document.querySelector('td.cell.active') as HTMLInputElement | HTMLTextAreaElement)?.scrollIntoView({ ;(document.querySelector('td.cell.active') as HTMLInputElement | HTMLTextAreaElement)?.scrollIntoView({
behavior: 'smooth', behavior: 'smooth',
}) })
return true return true
} else if (!paginationDataRef.value?.isLastPage) { } else if (!paginationDataRef.value?.isLastPage) {
await changePageWithLoading(paginationDataRef.value?.page! + 1) await changePage?.(paginationDataRef.value?.page! + 1)
await nextTick() await nextTick()
activeCell.row = 0 makeActive(0, 0)
activeCell.col = 0
return true return true
} }
} }
} else if (e.key === 'ArrowDown') { } else if (!e.shiftKey && e.key === 'ArrowUp') {
if (activeCell.row === 0 && !paginationDataRef.value?.isFirstPage) {
e.preventDefault()
await changePage?.(paginationDataRef.value?.page! - 1)
await nextTick()
makeActive((paginationDataRef.value?.pageSize ?? 25) - 1, activeCell.col!)
return true
}
} else if (!e.shiftKey && e.key === 'ArrowDown') {
if (activeCell.row === dataRef.value.length - 1) { if (activeCell.row === dataRef.value.length - 1) {
e.preventDefault() e.preventDefault()
editEnabled.value = false
if (paginationDataRef.value?.isLastPage && isAddingEmptyRowAllowed.value) { if (paginationDataRef.value?.isLastPage && isAddingEmptyRowAllowed.value) {
addEmptyRow() addEmptyRow()
activeCell.row = dataRef.value.length - 1
activeCell.col = 0
resetSelectedRange() resetSelectedRange()
await nextTick() makeActive(dataRef.value.length - 1, activeCell.col!)
// await nextTick()
;(document.querySelector('td.cell.active') as HTMLInputElement | HTMLTextAreaElement)?.scrollIntoView({ ;(document.querySelector('td.cell.active') as HTMLInputElement | HTMLTextAreaElement)?.scrollIntoView({
behavior: 'smooth', behavior: 'smooth',
}) })
return true return true
} else if (!paginationDataRef.value?.isLastPage) { } else if (!paginationDataRef.value?.isLastPage) {
await changePageWithLoading(paginationDataRef.value?.page! + 1) await changePage?.(paginationDataRef.value?.page! + 1)
await nextTick() await nextTick()
activeCell.row = 0 makeActive(0, activeCell.col!)
activeCell.col = activeCell.col
return true return true
} }

Loading…
Cancel
Save