From d7211b8265475254ecec698ea5ecdac82748bea7 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Fri, 27 Oct 2023 13:59:31 +0000 Subject: [PATCH] fix: Fixed issue with dnd to last col and improved auto scrolling responsiveness --- .../components/smartsheet/grid/useColumnDrag.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts b/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts index 337ec0e25b..9a9fa621bd 100644 --- a/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts +++ b/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts @@ -31,9 +31,10 @@ export const useColumnDrag = ({ const nextToColField = toColIndex < fields.value.length - 1 ? fields.value[toColIndex + 1] : null const nextToViewCol = nextToColField ? gridViewCols.value[nextToColField.id!] : null - const newOrder = nextToViewCol - ? toViewCol.order! + (nextToViewCol.order! - toViewCol.order!) / 2 - : toBeReorderedViewCol.order! + 1 + const lastCol = fields.value[fields.value.length - 1] + const lastViewCol = gridViewCols.value[lastCol.id!] + + const newOrder = nextToViewCol ? toViewCol.order! + (nextToViewCol.order! - toViewCol.order!) / 2 : lastViewCol.order! + 1 const oldOrder = toBeReorderedViewCol.order toBeReorderedViewCol.order = newOrder @@ -128,13 +129,13 @@ export const useColumnDrag = ({ const remInPx = parseFloat(getComputedStyle(document.documentElement).fontSize) - if (x > width.value * 0.5) { + if (x < leftSidebarWidth.value + 1 * remInPx) { setTimeout(() => { - gridWrapper.value!.scrollLeft += 2.5 + gridWrapper.value!.scrollLeft -= 2.5 }, 250) - } else if (x < leftSidebarWidth.value + 10 * remInPx) { + } else if (width.value - x - leftSidebarWidth.value < 15 * remInPx) { setTimeout(() => { - gridWrapper.value!.scrollLeft -= 2.5 + gridWrapper.value!.scrollLeft += 2.5 }, 250) } }