Browse Source

feat(gui): on new row creation focus on first input cell

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4968/head
Pranav C 2 years ago
parent
commit
27e61dde57
  1. 8
      packages/nc-gui/components/smartsheet/Grid.vue

8
packages/nc-gui/components/smartsheet/Grid.vue

@ -45,6 +45,7 @@ import {
useViewData, useViewData,
watch, watch,
} from '#imports' } from '#imports'
import { querySelector } from 'ultrahtml/selector'
import type { Row } from '~/lib' import type { Row } from '~/lib'
const { t } = useI18n() const { t } = useI18n()
@ -279,6 +280,12 @@ const {
if (isAddingEmptyRowAllowed) { if (isAddingEmptyRowAllowed) {
$e('c:shortcut', { key: 'ALT + R' }) $e('c:shortcut', { key: 'ALT + R' })
addEmptyRow() addEmptyRow()
activeCell.row = data.value.length - 1
activeCell.col = 0
makeEditable(data.value[activeCell.row], fields.value[activeCell.col])
nextTick(() => {
(document.querySelector('td.cell.active')?.querySelector('input,textarea') as HTMLInputElement | HTMLTextAreaElement)?.focus()
})
} }
break break
} }
@ -448,6 +455,7 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate =
} }
function makeEditable(row: Row, col: ColumnType) { function makeEditable(row: Row, col: ColumnType) {
console.log(row, col)
if (!hasEditPermission || editEnabled || isView) { if (!hasEditPermission || editEnabled || isView) {
return return
} }

Loading…
Cancel
Save