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

🐛Meta in merged cell was unpredicted because of unsorted cellInfos #2854

Open
1 task
linwaiwai opened this issue Aug 12, 2024 · 0 comments
Open
1 task
Labels
💤 inactive 不活跃的 Issue 或 PR, 30天没有回复 next 2.0-next 版本的问题

Comments

@linwaiwai
Copy link

linwaiwai commented Aug 12, 2024

🏷 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

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
@github-actions github-actions bot added the next 2.0-next 版本的问题 label Aug 12, 2024
@github-actions github-actions bot added the 💤 inactive 不活跃的 Issue 或 PR, 30天没有回复 label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💤 inactive 不活跃的 Issue 或 PR, 30天没有回复 next 2.0-next 版本的问题
Projects
None yet
Development

No branches or pull requests

1 participant