Skip to content

Commit 1d51585

Browse files
authored
fix: Input Tables cannot paste more rows than number of visible rows (#2152)
Resolves #2089
1 parent a2d5d5f commit 1d51585

2 files changed

Lines changed: 10 additions & 28 deletions

File tree

packages/grid/src/Grid.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,7 @@ class Grid extends PureComponent<GridProps, GridState> {
14971497
const { columnCount, rowCount } = model;
14981498
let ranges = selectedRanges;
14991499
// If each cell is a single selection, we need to update the selection to map to the newly pasted data
1500+
// Check for
15001501
if (
15011502
ranges.every(
15021503
range =>
@@ -1518,16 +1519,6 @@ class Grid extends PureComponent<GridProps, GridState> {
15181519
this.setSelectedRanges(ranges);
15191520
}
15201521

1521-
if (
1522-
!ranges.every(
1523-
range =>
1524-
GridRange.rowCount([range]) === tableHeight &&
1525-
GridRange.columnCount([range]) === tableWidth
1526-
)
1527-
) {
1528-
throw new PasteError('Copy and paste area are not same size.');
1529-
}
1530-
15311522
const edits: EditOperation[] = [];
15321523
ranges.forEach(range => {
15331524
for (let x = 0; x < tableWidth; x += 1) {

packages/iris-grid/src/IrisGridTableModelTemplate.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ class IrisGridTableModelTemplate<
10361036
*/
10371037
pendingRow(y: ModelIndex): ModelIndex | null {
10381038
const pendingRow = y - this.floatingTopRowCount - this.table.size;
1039-
if (pendingRow >= 0 && pendingRow < this.pendingNewRowCount) {
1039+
if (pendingRow >= 0) {
10401040
return pendingRow;
10411041
}
10421042

@@ -1633,7 +1633,11 @@ class IrisGridTableModelTemplate<
16331633

16341634
isEditableRange(range: GridRange): boolean {
16351635
// Make sure we have an input table and a valid range
1636-
if (this.inputTable == null || !GridRange.isBounded(range)) {
1636+
if (
1637+
this.inputTable == null ||
1638+
range.startRow == null ||
1639+
range.endRow == null
1640+
) {
16371641
return false;
16381642
}
16391643

@@ -1645,12 +1649,10 @@ class IrisGridTableModelTemplate<
16451649
this.isPendingRow(range.startRow) && this.isPendingRow(range.endRow);
16461650

16471651
let isKeyColumnInRange = false;
1652+
assertNotNull(range.startColumn);
16481653
// Check if any of the columns in grid range are key columns
1649-
for (
1650-
let column = range.startColumn;
1651-
column <= range.endColumn;
1652-
column += 1
1653-
) {
1654+
const bound = range.endColumn ?? this.table.size;
1655+
for (let column = range.startColumn; column <= bound; column += 1) {
16541656
if (this.isKeyColumn(column)) {
16551657
isKeyColumnInRange = true;
16561658
break;
@@ -1663,17 +1665,6 @@ class IrisGridTableModelTemplate<
16631665
return false;
16641666
}
16651667

1666-
// Editing the aggregations/totals which are floating above/below is not allowed
1667-
if (
1668-
range.startRow < this.floatingTopRowCount ||
1669-
range.startRow >=
1670-
this.floatingTopRowCount + this.table.size + this.pendingRowCount ||
1671-
range.endRow >=
1672-
this.floatingTopRowCount + this.table.size + this.pendingRowCount
1673-
) {
1674-
return false;
1675-
}
1676-
16771668
return true;
16781669
}
16791670

0 commit comments

Comments
 (0)