From d11fa385c565d3030dc5fda969a23d5c9beeea69 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 12 Oct 2022 20:28:46 +0530 Subject: [PATCH 1/2] refactor(gui): trigger scroll to cell only on key navigation Signed-off-by: Pranav C --- .../nc-gui/components/smartsheet/Grid.vue | 39 ++++++++++++------- .../composables/useMultiSelect/index.ts | 23 +++++++++-- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 9ab3188926..10bbf9d478 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -107,6 +107,19 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange isPkAvail, clearCell, makeEditable, + () => { + if (selected.row !== null && selected.col !== null) { + // get active cell + const td = tbodyEl.value?.querySelectorAll('tr')[selected.row]?.querySelectorAll('td')[selected.col + 1] + if (!td) return + // scroll into the active cell + td.scrollIntoView({ + behavior: 'smooth', + block: 'end', + inline: 'end', + }) + } + }, ) onMounted(loadGridViewColumns) @@ -353,19 +366,19 @@ watch( const tbodyEl = ref() -watch([() => selected.row, () => selected.col], ([row, col]) => { - if (row !== null && col !== null) { - // get active cell - const td = tbodyEl.value?.querySelectorAll('tr')[row]?.querySelectorAll('td')[col + 1] - if (!td) return - // scroll into the active cell - td.scrollIntoView({ - behavior: 'smooth', - block: 'end', - inline: 'end', - }) - } -}) +// watch([() => selected.row, () => selected.col], ([row, col]) => { +// if (row !== null && col !== null) { +// // get active cell +// const td = tbodyEl.value?.querySelectorAll('tr')[row]?.querySelectorAll('td')[col + 1] +// if (!td) return +// // scroll into the active cell +// td.scrollIntoView({ +// behavior: 'smooth', +// block: 'end', +// inline: 'end', +// }) +// } +// })