From 8c32509b0c8b92748912229810e07c63cea6ad7c Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Fri, 11 Oct 2024 16:17:47 +0000 Subject: [PATCH] fix: calculation errors --- packages/nc-gui/composables/useMultiSelect/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useMultiSelect/index.ts b/packages/nc-gui/composables/useMultiSelect/index.ts index 14ad37d298..7d777c461c 100644 --- a/packages/nc-gui/composables/useMultiSelect/index.ts +++ b/packages/nc-gui/composables/useMultiSelect/index.ts @@ -853,6 +853,7 @@ export function useMultiSelect( const colsToPaste = unref(fields).slice(activeCell.col, activeCell.col + pasteMatrixCols) const { totalRows = 0, page = 1, pageSize = 100 } = unref(paginationDataRef)! + const totalRowsBeforeActiveCell = (page - 1) * pageSize + activeCell.row const availableRowsToUpdate = Math.max(0, totalRows - totalRowsBeforeActiveCell) const rowsToAdd = Math.max(0, selectionRowCount - availableRowsToUpdate) @@ -864,7 +865,7 @@ export function useMultiSelect( Math.min(selectionRowCount, rowsInCurrentPage - activeCell.row), availableRowsToUpdate, ) - const recordsUpdatedInSubsequentPages = Math.max(0, availableRowsToUpdate - recordsUpdatedInCurrentPage) + const recordsUpdatedInSubsequentPages = Math.max(0, selectionRowCount - recordsUpdatedInCurrentPage) let options = { continue: false, @@ -947,7 +948,10 @@ export function useMultiSelect( } selectedRange.startRange({ row: activeCell.row, col: activeCell.col }) - selectedRange.endRange({ row: activeCell.row + selectionRowCount - 1, col: activeCell.col + pasteMatrixCols - 1 }) + selectedRange.endRange({ + row: activeCell.row + recordsUpdatedInCurrentPage - 1, + col: activeCell.col + pasteMatrixCols - 1, + }) } else { if (selectedRange.isSingleCell()) { const rowObj = unref(data)[activeCell.row]