From 27e61dde57954f2f2f66b16a21874470aa4955b4 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 30 Jan 2023 12:05:45 +0530 Subject: [PATCH] feat(gui): on new row creation focus on first input cell Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/Grid.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 343da347d3..77804dc1c2 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -45,6 +45,7 @@ import { useViewData, watch, } from '#imports' +import { querySelector } from 'ultrahtml/selector' import type { Row } from '~/lib' const { t } = useI18n() @@ -279,6 +280,12 @@ const { if (isAddingEmptyRowAllowed) { $e('c:shortcut', { key: 'ALT + R' }) 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 } @@ -448,6 +455,7 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate = } function makeEditable(row: Row, col: ColumnType) { + console.log(row, col) if (!hasEditPermission || editEnabled || isView) { return }