Skip to content

Commit

Permalink
fix: 修复文本设为左对齐时, 角头文本没有垂直对齐的问题 (#2960)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 authored Nov 7, 2024
1 parent dd21ab9 commit af8c968
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7575,8 +7575,8 @@ Array [
"actualTextWidth": 242,
"height": 56,
"multiLineActualTexts": Array [
"类别类别类别类别类别类别类",
"别类别类别类别",
"类别类别类别类别类别类别",
"类别类别类别类别",
],
"originalText": "类别类别类别类别类别类别类别类别类别类别",
"width": 180,
Expand Down
19 changes: 19 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/corner-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,23 @@ describe('PivotSheet Corner Tests', () => {

expect(cornerCell.getActualText()).toEqual(cornerExtraFieldText);
});

test('should keep vertical alignment for tree mode when text align is left', async () => {
s2.setOptions({
hierarchyType: 'tree',
});
s2.setTheme({
cornerCell: {
bolderText: {
textAlign: 'left',
},
},
});
await s2.render();

s2.facet.getCornerNodes().forEach((node) => {
expect(node.x).toEqual(0);
expect(node.width).toEqual(120);
});
});
});
2 changes: 1 addition & 1 deletion packages/s2-core/src/cell/corner-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class CornerCell extends HeaderCell<CornerHeaderConfig> {
protected getTreeIconWidth() {
const { size, margin } = this.getStyle()!.icon!;

return this.showTreeIcon() ? size! + margin!.right! : 0;
return this.spreadsheet.isHierarchyTreeType() ? size! + margin!.right! : 0;
}

public getMaxTextWidth(): number {
Expand Down

0 comments on commit af8c968

Please sign in to comment.