Skip to content

Commit

Permalink
fix(grid): only operate selected data which is visible
Browse files Browse the repository at this point in the history
  • Loading branch information
minlovehua committed Feb 21, 2025
1 parent 684b952 commit 20563a2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/grid/src/services/selection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ export class AITableGridSelectionService {

selectCells(startCell: AIRecordFieldIdPath, endCell?: AIRecordFieldIdPath) {
const [startRecordId, startFieldId] = startCell;
const records = this.aiTable.records();
const fields = this.aiTable.fields();
const records = this.aiTable.context!.linearRows();
const fields = AITable.getVisibleFields(this.aiTable);
const selectedCells = new Set<string>();

if (!endCell) {
selectedCells.add(`${startRecordId}:${startFieldId}`);
} else {
const [endRecordId, endFieldId] = endCell;

const startRowIndex = records.findIndex((record) => record._id === startRecordId);
const endRowIndex = records.findIndex((record) => record._id === endRecordId);
const startColIndex = fields.findIndex((field) => field._id === startFieldId);
const endColIndex = fields.findIndex((field) => field._id === endFieldId);
const startRowIndex = this.aiTable.context!.visibleRowsIndexMap().get(startRecordId)!;
const endRowIndex = this.aiTable.context!.visibleRowsIndexMap().get(endRecordId)!;
const startColIndex = this.aiTable.context!.visibleColumnsIndexMap().get(startFieldId)!;
const endColIndex = this.aiTable.context!.visibleColumnsIndexMap().get(endFieldId)!;

const minRowIndex = Math.min(startRowIndex, endRowIndex);
const maxRowIndex = Math.max(startRowIndex, endRowIndex);
Expand Down

0 comments on commit 20563a2

Please sign in to comment.