From 03e5a995be45f22604684913268ab7cb3e80df69 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 1 Jun 2023 14:57:18 +0530 Subject: [PATCH] feat: on clicking display cell scroll to the beginning Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/Grid.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index edb98665a0..bfc8996870 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -178,7 +178,8 @@ const getContainerScrollForElement = ( * If the element is below the container, scroll down (positive) * If the element is above the container, scroll up (negative) */ - scroll.top = relativePos.bottom + (offset?.bottom || 0) > 0 + scroll.top = + relativePos.bottom + (offset?.bottom || 0) > 0 ? container.scrollTop + relativePos.bottom + (offset?.bottom || 0) + extraOffset : relativePos.top - (offset?.top || 0) < 0 ? container.scrollTop + relativePos.top - (offset?.top || 0) - extraOffset @@ -351,6 +352,12 @@ function scrollToCell(row?: number | null, col?: number | null) { const { height: headerHeight } = tableHead.value!.getBoundingClientRect() const tdScroll = getContainerScrollForElement(td, gridWrapper.value, { top: headerHeight, bottom: 9, right: 9 }) + // if first column set left to 0 since it's sticky it will be visible and calculated value will be wrong + // setting left to 0 will make it scroll to the left + if (col === 0) { + tdScroll.left = 0 + } + if (rows && row === rows.length - 2) { // if last row make 'Add New Row' visible gridWrapper.value.scrollTo({