Skip to content

🐛 Confusing textAlign behavior of "Grand total cell" #1357

@Dhalsimzhao

Description

@Dhalsimzhao

🏷 Version

Package Version
@antv/s2 - 1.17.0
@antv/s2-react -

🖋 Description

S2 PivotSheet

When I set hideMeasureColumn to true or false, the grand total cell has a different textAlign behavior.
The column grand total cell uses the textAlign style of DataCell when set hideMeasureColumn to false, but hard code the style when hideMeasureColumn is set to true

⌨️ Code Snapshots

/* col-cell.ts */
protected getTextStyle(): TextTheme {
  const { isLeaf } = this.meta;
  const textStyle = this.getOriginalTextStyle();
  const hideMeasureColumn =
    this.spreadsheet.options.style.colCfg.hideMeasureColumn;
  let textAlign: TextAlign;
  let textBaseline: TextBaseline;
  if (isLeaf && !hideMeasureColumn) {
    textAlign = this.theme.dataCell.text.textAlign;
    textBaseline = this.theme.dataCell.text.textBaseline;
  } else {
    // 为方便 getTextAreaRange 计算文字位置
    // textAlign 固定为 center
    textAlign = 'center';
    textBaseline = 'middle';
  }
  return { ...textStyle, textAlign, textBaseline };
}

🔗 Reproduce Link

https://codesandbox.io/s/great-andras-jj1jr7

🤔 Steps to Reproduce

  1. Create a PivotSheet
  2. Set options which made the column grand total cell display as a leaf node
  3. s2.render()

😊 Expected Behavior

The column grand total cell should renders with boldText style of ColCell

😅 Current Behavior

Shown in the codesandbox link

💻 System information

chrome: 101.0, windows 10

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions