Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Input Tables cannot paste more rows than number of visible rows #2313

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions packages/grid/src/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,7 @@ class Grid extends PureComponent<GridProps, GridState> {
const { columnCount, rowCount } = model;
let ranges = selectedRanges;
// If each cell is a single selection, we need to update the selection to map to the newly pasted data
// Check for
if (
ranges.every(
range =>
Expand All @@ -1518,16 +1519,6 @@ class Grid extends PureComponent<GridProps, GridState> {
this.setSelectedRanges(ranges);
}

if (
!ranges.every(
range =>
GridRange.rowCount([range]) === tableHeight &&
GridRange.columnCount([range]) === tableWidth
)
) {
throw new PasteError('Copy and paste area are not same size.');
}

const edits: EditOperation[] = [];
ranges.forEach(range => {
for (let x = 0; x < tableWidth; x += 1) {
Expand Down
27 changes: 9 additions & 18 deletions packages/iris-grid/src/IrisGridTableModelTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ class IrisGridTableModelTemplate<
*/
pendingRow(y: ModelIndex): ModelIndex | null {
const pendingRow = y - this.floatingTopRowCount - this.table.size;
if (pendingRow >= 0 && pendingRow < this.pendingNewRowCount) {
if (pendingRow >= 0) {
return pendingRow;
}

Expand Down Expand Up @@ -1635,7 +1635,11 @@ class IrisGridTableModelTemplate<

isEditableRange(range: GridRange): boolean {
// Make sure we have an input table and a valid range
if (this.inputTable == null || !GridRange.isBounded(range)) {
if (
this.inputTable == null ||
range.startRow == null ||
range.endRow == null
) {
return false;
}

Expand All @@ -1647,12 +1651,10 @@ class IrisGridTableModelTemplate<
this.isPendingRow(range.startRow) && this.isPendingRow(range.endRow);

let isKeyColumnInRange = false;
assertNotNull(range.startColumn);
// Check if any of the columns in grid range are key columns
for (
let column = range.startColumn;
column <= range.endColumn;
column += 1
) {
const bound = range.endColumn ?? this.table.size;
for (let column = range.startColumn; column <= bound; column += 1) {
if (this.isKeyColumn(column)) {
isKeyColumnInRange = true;
break;
Expand All @@ -1665,17 +1667,6 @@ class IrisGridTableModelTemplate<
return false;
}

// Editing the aggregations/totals which are floating above/below is not allowed
if (
range.startRow < this.floatingTopRowCount ||
range.startRow >=
this.floatingTopRowCount + this.table.size + this.pendingRowCount ||
range.endRow >=
this.floatingTopRowCount + this.table.size + this.pendingRowCount
) {
return false;
}

return true;
}

Expand Down
Loading