Skip to content

Commit

Permalink
fix: 修复Grid组件在渲染Selection和Expand时可能会出现的重复项问题 (#2064)
Browse files Browse the repository at this point in the history
Co-authored-by: daitingyuan <[email protected]>
  • Loading branch information
Tinsson and daitingyuan authored Jul 26, 2024
1 parent 3cd59f5 commit f73b52c
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions packages/zent/src/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,16 @@ export class Grid<
const selectionColumn = this.getSelectionColumn(props, columnsArg);

if (selectionColumn) {
const maySelectionColumn = columns[0];
if (
maySelectionColumn &&
['selection-column', 'selection-column-single'].indexOf(
maySelectionColumn.key
) !== -1
) {
columns[0] = { ...columns[0], ...selectionColumn };
const selectionIndex = columns.findIndex(
columns =>
columns.key === 'selection-column' ||
columns.key === 'selection-column-single'
);
if (selectionIndex !== -1) {
columns[selectionIndex] = {
...columns[selectionIndex],
...selectionColumn,
};
} else {
columns.unshift(selectionColumn);
}
Expand All @@ -464,7 +466,17 @@ export class Grid<
if (hasLeft) {
expandColumn.fixed = 'left';
}
columns.unshift(expandColumn);
const expandIndex = columns.findIndex(
columns => columns.key === expandColumn.key
);
if (expandIndex !== -1) {
columns[expandIndex] = {
...columns[expandIndex],
...expandColumn,
};
} else {
columns.unshift(expandColumn);
}
}

if (!isStoreColumns) {
Expand Down

0 comments on commit f73b52c

Please sign in to comment.