From a75be8b2280e08af986ac7794b52875a58a6291f Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 15 Oct 2022 13:08:16 +0300 Subject: [PATCH] feat: include add new column in view if most right column Signed-off-by: mertmit --- packages/nc-gui/components/smartsheet/Grid.vue | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 31c183cb11..f09ad2a10e 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -171,7 +171,8 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange if (row !== undefined && col !== undefined && row !== null && col !== null) { // get active cell const rows = tbodyEl.value?.querySelectorAll('tr') - const td = rows?.[row].querySelectorAll('td')[col === 0 ? 0 : col + 1] + const cols = rows?.[row].querySelectorAll('td') + const td = cols?.[col === 0 ? 0 : col + 1] if (!td || !gridWrapper.value) return @@ -182,7 +183,20 @@ const { selectCell, selectBlock, selectedRange, clearRangeRows, startSelectRange // if last row make 'Add New Row' visible gridWrapper.value.scrollTo({ top: gridWrapper.value.scrollHeight, - left: tdScroll.left, + left: + cols && col === cols.length - 2 // if corner cell + ? gridWrapper.value.scrollWidth + : tdScroll.left, + behavior: 'smooth', + }) + return + } + + if (cols && col === cols.length - 2) { + // if last column make 'Add New Column' visible + gridWrapper.value.scrollTo({ + top: tdScroll.top, + left: gridWrapper.value.scrollWidth, behavior: 'smooth', }) return