antvis / antvis/S2

🐛Meta in merged cell was unpredicted because of unsorted cellInfos

Open
#2,854 0 comments 0 reactions 0 assignees View on GitHub
💤 inactive next
Dominant language
TypeScript
Stars
1.7k
Forks
220
PR merge metrics
No merged PRs in 30d

Description

### 🏷 Version

| Package | Version |
| -------------- | ------- |
| @antv/s2 | 2.0.0-next.23 |
| @antv/s2-vue | 2.0.0-next.14 |

### Sheet Type

- [ ] PivotSheet

### 🖋 Description

When scrolling the spreadsheet, the return of getMeta function is confusing after extending class MergedCell . It returns data or null .

### ⌨️ Code Snapshots

```javascript
export const getTempMergedCell = (
allVisibleCells: DataCell[],
sheet?: SpreadSheet,
cellsInfos: MergedCellInfo[] = [],
): TempMergedCell => {
const { cellsMeta, cells, invisibleCellInfo } = getVisibleInfo(
cellsInfos,
allVisibleCells,
);
let viewMeta: ViewMeta | Node | undefined = cellsMeta;
let mergedAllCells: DataCell[] = cells;
// some cells are invisible and some cells are visible
const isPartiallyVisible =
invisibleCellInfo?.length > 0 &&
invisibleCellInfo.length < cellsInfos.length;

// 当 MergedCell 只有部分在可视区域时,在此获取 MergedCell 不在可视区域内的 cells
if (isPartiallyVisible) {
const { cells: invisibleCells, cellsMeta: invisibleMeta } =
getInvisibleInfo(invisibleCellInfo, sheet!);

viewMeta = viewMeta || invisibleMeta;
mergedAllCells = cells.concat(invisibleCells); // this is the boob which will explode anytime
}

if (!isEmpty(cells) && !viewMeta) {
// 如果没有指定合并后的文本绘制的位置,默认画在选择的第一个单元格内
viewMeta = mergedAllCells[0]?.getMeta() as ViewMeta;
}

return {
cells: mergedAllCells,
viewMeta: viewMeta as ViewMeta,
};
};
```
When scolling the spreadsheet, invisibleCells may be any position includes top, bottom, left , right . But here , Simplely add it to the tail. So the viewMeta will be data or null .

mergedAllCells should be sorted by colIndex and rowIndex .

### 🔗 Reproduce Link

### 🤔 Steps to Reproduce

### 😊 Expected Behavior

viewMeta should be data anytimes

### 😅 Current Behavior

### 💻 System information

| Environment | Info |
| ------- | ------- |
| System | |
| Browser | |

Contributor guide

Open the contributing guide

Research direction

Start at the getTempMergedCell function shown in the issue and trace getVisibleInfo and getInvisibleInfo to understand the cell ordering. Check the merged-cell behavior while scrolling, especially when invisible cells occur above, below, left, or right. Done means mergedAllCells is ordered by colIndex and rowIndex and viewMeta remains data rather than becoming null.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.