From cd4f88a0d9e9c609c5ccb140b89978fd013ef3c5 Mon Sep 17 00:00:00 2001 From: JuZe Date: Thu, 26 Oct 2023 09:41:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E6=A0=91=E7=8A=B6=E8=A7=92=E5=A4=B4?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E6=9C=89=E4=B8=A4=E4=B8=AAicon=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=86=85=E5=AE=B9=E4=B8=8Ebox=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E6=81=B0=E5=A5=BD=E7=9B=B8=E7=AD=89=EF=BC=8C=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-core/src/facet/pivot-facet.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/s2-core/src/facet/pivot-facet.ts b/packages/s2-core/src/facet/pivot-facet.ts index c5da151310..8b947a60ff 100644 --- a/packages/s2-core/src/facet/pivot-facet.ts +++ b/packages/s2-core/src/facet/pivot-facet.ts @@ -745,8 +745,10 @@ export class PivotFacet extends BaseFacet { .join('/'); const { bolderText: cornerCellTextStyle, icon: cornerIconStyle } = this.spreadsheet.theme.cornerCell; - // 初始化角头时,保证其在树形模式下不换行,给与两个icon的宽度空余(tree icon 和 action icon),减少复杂的 action icon 判断 + // 初始化角头时,保证其在树形模式下不换行 + // 给与两个icon的宽度空余(tree icon 和 action icon),减少复杂的 action icon 判断 const maxLabelWidth = + 1 + this.spreadsheet.measureTextWidth(treeHeaderLabel, cornerCellTextStyle) + cornerIconStyle.size * 2 + cornerIconStyle.margin?.left + From f67c70e758b839becb43544dbb64d68a191666bc Mon Sep 17 00:00:00 2001 From: JuZe Date: Thu, 26 Oct 2023 10:01:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E6=A0=91=E7=8A=B6=E8=A7=92=E5=A4=B4?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E6=9C=89=E4=B8=A4=E4=B8=AAicon=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=86=85=E5=AE=B9=E4=B8=8Ebox=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E6=81=B0=E5=A5=BD=E7=9B=B8=E7=AD=89=EF=BC=8C=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=20close:2389?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spreadsheet/__snapshots__/corner-spec.ts.snap | 12 ++++++------ .../spreadsheet/spread-sheet-tree-mode-spec.ts | 2 +- .../unit/facet/layout/col-node-width-spec.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/s2-core/__tests__/spreadsheet/__snapshots__/corner-spec.ts.snap b/packages/s2-core/__tests__/spreadsheet/__snapshots__/corner-spec.ts.snap index b3dc716fbd..f3430d0399 100644 --- a/packages/s2-core/__tests__/spreadsheet/__snapshots__/corner-spec.ts.snap +++ b/packages/s2-core/__tests__/spreadsheet/__snapshots__/corner-spec.ts.snap @@ -188,7 +188,7 @@ Array [ "rowIndex": undefined, "seriesNumberWidth": 0, "value": "province/city/数值", - "width": 150, + "width": 151, "x": 0, "y": 0, }, @@ -253,7 +253,7 @@ Array [ "rowIndex": undefined, "seriesNumberWidth": 80, "value": "province/city/数值", - "width": 150, + "width": 151, "x": 80, "y": 0, }, @@ -448,7 +448,7 @@ Array [ "rowIndex": undefined, "seriesNumberWidth": 0, "value": "province/city", - "width": 122, + "width": 123, "x": 0, "y": 0, }, @@ -513,7 +513,7 @@ Array [ "rowIndex": undefined, "seriesNumberWidth": 80, "value": "province/city", - "width": 122, + "width": 123, "x": 80, "y": 0, }, @@ -708,7 +708,7 @@ Array [ "rowIndex": undefined, "seriesNumberWidth": 0, "value": "province/city", - "width": 122, + "width": 123, "x": 0, "y": 0, }, @@ -773,7 +773,7 @@ Array [ "rowIndex": undefined, "seriesNumberWidth": 80, "value": "province/city", - "width": 122, + "width": 123, "x": 80, "y": 0, }, diff --git a/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts b/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts index 510c28565a..b6b542dd6b 100644 --- a/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts +++ b/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts @@ -26,7 +26,7 @@ describe('SpreadSheet Tree Mode Tests', () => { s2.render(); const rowsHierarchyWidth = s2.facet.layoutResult.rowsHierarchy.width; - expect(Math.round(rowsHierarchyWidth)).toEqual(123); + expect(Math.round(rowsHierarchyWidth)).toEqual(124); // 行头维度均更改为较长的 name const newDataCfg: S2DataConfig = { diff --git a/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts b/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts index 49217dcd9f..f31e370a9b 100644 --- a/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts @@ -53,7 +53,7 @@ describe('Col width Test', () => { }); s2.render(); const { colLeafNodes } = s2.facet.layoutResult; - expect(Math.round(colLeafNodes[0].width)).toBe(339); + expect(Math.round(colLeafNodes[0].width)).toBe(338); }); test('get correct width in layoutWidthType adaptive tree mode when enable seriesnumber', () => { @@ -63,7 +63,7 @@ describe('Col width Test', () => { }); s2.render(); const { colLeafNodes } = s2.facet.layoutResult; - expect(Math.round(colLeafNodes[0].width)).toBe(299); + expect(Math.round(colLeafNodes[0].width)).toBe(298); }); test('get correct width in layoutWidthType compact mode', () => { From 29caca5f675a7ad210b17d57912d9e641c49c45d Mon Sep 17 00:00:00 2001 From: JuZe Date: Thu, 26 Oct 2023 10:34:56 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E6=A0=91=E7=8A=B6=E8=A7=92=E5=A4=B4?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E6=9C=89=E4=B8=A4=E4=B8=AAicon=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=86=85=E5=AE=B9=E4=B8=8Ebox=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E6=81=B0=E5=A5=BD=E7=9B=B8=E7=AD=89=EF=BC=8C=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=20close:2389?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spread-sheet-tree-mode-spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts b/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts index b6b542dd6b..d7761e11b5 100644 --- a/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts +++ b/packages/s2-core/__tests__/spreadsheet/spread-sheet-tree-mode-spec.ts @@ -49,5 +49,39 @@ describe('SpreadSheet Tree Mode Tests', () => { rowsHierarchyWidth, ); }); + + // https://github.com/antvis/S2/issues/2389 + test('the corner should only have one line with action icon', () => { + // 行头维度更改为较长的 name + const newDataCfg: S2DataConfig = { + ...mockDataConfig, + meta: [ + { + field: 'province', + name: '省1234567890份', + }, + { + field: 'city', + name: '城1234567890市', + }, + ], + }; + // 添加icon + const newS2Options: S2Options = { + ...s2Options, + headerActionIcons: [ + { + iconNames: ['SortDownSelected'], + belongsCell: 'cornerCell', + }, + ], + }; + const s2 = new PivotSheet(container, newDataCfg, newS2Options); + s2.render(); + + // 检查文本是否只有一行 + const textLen = s2.facet.cornerHeader.cfg.children[0].textShapes.length; + expect(textLen).toEqual(1); + }); }); }); From ee0507a06dc510c61f21c343176596498f637ad9 Mon Sep 17 00:00:00 2001 From: JuZe Date: Thu, 26 Oct 2023 10:42:41 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-core/src/facet/pivot-facet.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/s2-core/src/facet/pivot-facet.ts b/packages/s2-core/src/facet/pivot-facet.ts index 8b947a60ff..eede09c795 100644 --- a/packages/s2-core/src/facet/pivot-facet.ts +++ b/packages/s2-core/src/facet/pivot-facet.ts @@ -747,6 +747,7 @@ export class PivotFacet extends BaseFacet { this.spreadsheet.theme.cornerCell; // 初始化角头时,保证其在树形模式下不换行 // 给与两个icon的宽度空余(tree icon 和 action icon),减少复杂的 action icon 判断 + // 额外增加 1,当内容和容器宽度恰好相等时会出现换行 const maxLabelWidth = 1 + this.spreadsheet.measureTextWidth(treeHeaderLabel, cornerCellTextStyle) +