From af8c96809fd0e52f1da81e2a1c082a5f5b0b122a Mon Sep 17 00:00:00 2001 From: Jinke Li Date: Thu, 7 Nov 2024 16:20:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E8=AE=BE=E4=B8=BA=E5=B7=A6=E5=AF=B9=E9=BD=90=E6=97=B6,=20?= =?UTF-8?q?=E8=A7=92=E5=A4=B4=E6=96=87=E6=9C=AC=E6=B2=A1=E6=9C=89=E5=9E=82?= =?UTF-8?q?=E7=9B=B4=E5=AF=B9=E9=BD=90=E7=9A=84=E9=97=AE=E9=A2=98=20(#2960?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../multi-line-text-spec.ts.snap | 4 ++-- .../__tests__/spreadsheet/corner-spec.ts | 19 +++++++++++++++++++ packages/s2-core/src/cell/corner-cell.ts | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap b/packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap index ed4293c5e8..d3bb3a1672 100644 --- a/packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap +++ b/packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap @@ -7575,8 +7575,8 @@ Array [ "actualTextWidth": 242, "height": 56, "multiLineActualTexts": Array [ - "类别类别类别类别类别类别类", - "别类别类别类别", + "类别类别类别类别类别类别", + "类别类别类别类别", ], "originalText": "类别类别类别类别类别类别类别类别类别类别", "width": 180, diff --git a/packages/s2-core/__tests__/spreadsheet/corner-spec.ts b/packages/s2-core/__tests__/spreadsheet/corner-spec.ts index bea8aa3fdc..0ce3904ee2 100644 --- a/packages/s2-core/__tests__/spreadsheet/corner-spec.ts +++ b/packages/s2-core/__tests__/spreadsheet/corner-spec.ts @@ -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); + }); + }); }); diff --git a/packages/s2-core/src/cell/corner-cell.ts b/packages/s2-core/src/cell/corner-cell.ts index 240be80c55..c994183c85 100644 --- a/packages/s2-core/src/cell/corner-cell.ts +++ b/packages/s2-core/src/cell/corner-cell.ts @@ -209,7 +209,7 @@ export class CornerCell extends HeaderCell { 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 {