Skip to content

Commit 15be85d

Browse files
authored
fix: dataCell 始终按当前 meta.height 计算可展示行数 (#3339)
* fix: dataCell 始终按当前 meta.height 计算可展示行数 * fix: 修复单测
1 parent cfb94ea commit 15be85d

2 files changed

Lines changed: 55 additions & 67 deletions

File tree

‎packages/s2-core/__tests__/spreadsheet/__snapshots__/multi-line-text-spec.ts.snap‎

Lines changed: 52 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4385,13 +4385,12 @@ Array [
43854385
"width": 96,
43864386
},
43874387
Object {
4388-
"actualText": "236723672361111",
4389-
"actualTextHeight": 30,
4390-
"actualTextWidth": 99,
4388+
"actualText": "2367236723...",
4389+
"actualTextHeight": 15,
4390+
"actualTextWidth": 77,
43914391
"height": 30,
43924392
"multiLineActualTexts": Array [
4393-
"23672367236",
4394-
"1111",
4393+
"2367236723...",
43954394
],
43964395
"originalText": 236723672361111,
43974396
"width": 96,
@@ -5293,13 +5292,12 @@ Array [
52935292
exports[`SpreadSheet Multi Line Text Tests PivotSheet should calculate correctly max text width for default sort header action icons 5`] = `
52945293
Array [
52955294
Object {
5296-
"actualText": "236723672361111",
5297-
"actualTextHeight": 30,
5298-
"actualTextWidth": 100,
5295+
"actualText": "23672367236...",
5296+
"actualTextHeight": 15,
5297+
"actualTextWidth": 84,
52995298
"height": 30,
53005299
"multiLineActualTexts": Array [
5301-
"2367236723611",
5302-
"11",
5300+
"23672367236...",
53035301
],
53045302
"originalText": 236723672361111,
53055303
"width": 102,
@@ -7180,13 +7178,12 @@ Array [
71807178
exports[`SpreadSheet Multi Line Text Tests PivotSheet should calculate correctly max text width for headerActionIcons 5`] = `
71817179
Array [
71827180
Object {
7183-
"actualText": "236723672361111",
7184-
"actualTextHeight": 30,
7185-
"actualTextWidth": 100,
7181+
"actualText": "23672367236...",
7182+
"actualTextHeight": 15,
7183+
"actualTextWidth": 84,
71867184
"height": 30,
71877185
"multiLineActualTexts": Array [
7188-
"2367236723611",
7189-
"11",
7186+
"23672367236...",
71907187
],
71917188
"originalText": 236723672361111,
71927189
"width": 102,
@@ -8880,13 +8877,12 @@ Array [
88808877
exports[`SpreadSheet Multi Line Text Tests PivotSheet should get correctly row cell height priority if actual text not wrap 5`] = `
88818878
Array [
88828879
Object {
8883-
"actualText": "236723672361111",
8884-
"actualTextHeight": 30,
8885-
"actualTextWidth": 100,
8880+
"actualText": "23672367236...",
8881+
"actualTextHeight": 15,
8882+
"actualTextWidth": 84,
88868883
"height": 30,
88878884
"multiLineActualTexts": Array [
8888-
"2367236723611",
8889-
"11",
8885+
"23672367236...",
88908886
],
88918887
"originalText": 236723672361111,
88928888
"width": 102,
@@ -9578,13 +9574,12 @@ Array [
95789574
exports[`SpreadSheet Multi Line Text Tests PivotSheet should not adaptive adjust cell height if custom cell style less than actual text height by colCell.height 5`] = `
95799575
Array [
95809576
Object {
9581-
"actualText": "236723672361111",
9582-
"actualTextHeight": 30,
9583-
"actualTextWidth": 99,
9577+
"actualText": "2367236723...",
9578+
"actualTextHeight": 15,
9579+
"actualTextWidth": 77,
95849580
"height": 30,
95859581
"multiLineActualTexts": Array [
9586-
"23672367236",
9587-
"1111",
9582+
"2367236723...",
95889583
],
95899584
"originalText": 236723672361111,
95909585
"width": 96,
@@ -9979,13 +9974,12 @@ Array [
99799974
exports[`SpreadSheet Multi Line Text Tests PivotSheet should not adaptive adjust cell height if custom cell style less than actual text height by colCell.height() 5`] = `
99809975
Array [
99819976
Object {
9982-
"actualText": "236723672361111",
9983-
"actualTextHeight": 30,
9984-
"actualTextWidth": 99,
9977+
"actualText": "2367236723...",
9978+
"actualTextHeight": 15,
9979+
"actualTextWidth": 77,
99859980
"height": 30,
99869981
"multiLineActualTexts": Array [
9987-
"23672367236",
9988-
"1111",
9982+
"2367236723...",
99899983
],
99909984
"originalText": 236723672361111,
99919985
"width": 96,
@@ -10938,13 +10932,12 @@ Array [
1093810932
exports[`SpreadSheet Multi Line Text Tests PivotSheet should not adaptive adjust cell height if custom cell style more than actual text height by colCell.heightByField 5`] = `
1093910933
Array [
1094010934
Object {
10941-
"actualText": "236723672361111",
10942-
"actualTextHeight": 30,
10943-
"actualTextWidth": 99,
10935+
"actualText": "2367236723...",
10936+
"actualTextHeight": 15,
10937+
"actualTextWidth": 77,
1094410938
"height": 30,
1094510939
"multiLineActualTexts": Array [
10946-
"23672367236",
10947-
"1111",
10940+
"2367236723...",
1094810941
],
1094910942
"originalText": 236723672361111,
1095010943
"width": 96,
@@ -13182,13 +13175,12 @@ Array [
1318213175
exports[`SpreadSheet Multi Line Text Tests PivotSheet should render by infinity maxLines 5`] = `
1318313176
Array [
1318413177
Object {
13185-
"actualText": "236723672361111",
13186-
"actualTextHeight": 30,
13187-
"actualTextWidth": 99,
13178+
"actualText": "2367236723...",
13179+
"actualTextHeight": 15,
13180+
"actualTextWidth": 77,
1318813181
"height": 30,
1318913182
"multiLineActualTexts": Array [
13190-
"23672367236",
13191-
"1111",
13183+
"2367236723...",
1319213184
],
1319313185
"originalText": 236723672361111,
1319413186
"width": 96,
@@ -14826,13 +14818,12 @@ Array [
1482614818
exports[`SpreadSheet Multi Line Text Tests PivotSheet should render by maxLinesByField 5`] = `
1482714819
Array [
1482814820
Object {
14829-
"actualText": "236723672361111",
14830-
"actualTextHeight": 30,
14831-
"actualTextWidth": 100,
14821+
"actualText": "23672367236...",
14822+
"actualTextHeight": 15,
14823+
"actualTextWidth": 84,
1483214824
"height": 30,
1483314825
"multiLineActualTexts": Array [
14834-
"2367236723611",
14835-
"11",
14826+
"23672367236...",
1483614827
],
1483714828
"originalText": 236723672361111,
1483814829
"width": 102,
@@ -15932,13 +15923,12 @@ Array [
1593215923
exports[`SpreadSheet Multi Line Text Tests PivotSheet should render three max text lines 5`] = `
1593315924
Array [
1593415925
Object {
15935-
"actualText": "236723672361111",
15936-
"actualTextHeight": 30,
15937-
"actualTextWidth": 99,
15926+
"actualText": "2367236723...",
15927+
"actualTextHeight": 15,
15928+
"actualTextWidth": 77,
1593815929
"height": 30,
1593915930
"multiLineActualTexts": Array [
15940-
"23672367236",
15941-
"1111",
15931+
"2367236723...",
1594215932
],
1594315933
"originalText": 236723672361111,
1594415934
"width": 96,
@@ -16622,13 +16612,12 @@ Array [
1662216612
"width": 103,
1662316613
},
1662416614
Object {
16625-
"actualText": "236723672361111",
16626-
"actualTextHeight": 30,
16627-
"actualTextWidth": 100,
16615+
"actualText": "23672367236...",
16616+
"actualTextHeight": 15,
16617+
"actualTextWidth": 84,
1662816618
"height": 30,
1662916619
"multiLineActualTexts": Array [
16630-
"2367236723611",
16631-
"11",
16620+
"23672367236...",
1663216621
],
1663316622
"originalText": 236723672361111,
1663416623
"width": 103,
@@ -17311,13 +17300,12 @@ Array [
1731117300
exports[`SpreadSheet Multi Line Text Tests PivotSheet should render two max text lines 5`] = `
1731217301
Array [
1731317302
Object {
17314-
"actualText": "236723672361111",
17315-
"actualTextHeight": 30,
17316-
"actualTextWidth": 99,
17303+
"actualText": "2367236723...",
17304+
"actualTextHeight": 15,
17305+
"actualTextWidth": 77,
1731717306
"height": 30,
1731817307
"multiLineActualTexts": Array [
17319-
"23672367236",
17320-
"1111",
17308+
"2367236723...",
1732117309
],
1732217310
"originalText": 236723672361111,
1732317311
"width": 96,
@@ -17909,13 +17897,12 @@ Array [
1790917897
exports[`SpreadSheet Multi Line Text Tests PivotSheet should use actual text height for large max line 5`] = `
1791017898
Array [
1791117899
Object {
17912-
"actualText": "236723672361111",
17913-
"actualTextHeight": 30,
17914-
"actualTextWidth": 100,
17900+
"actualText": "23672367236...",
17901+
"actualTextHeight": 15,
17902+
"actualTextWidth": 84,
1791517903
"height": 30,
1791617904
"multiLineActualTexts": Array [
17917-
"2367236723611",
17918-
"11",
17905+
"23672367236...",
1791917906
],
1792017907
"originalText": 236723672361111,
1792117908
"width": 102,

‎packages/s2-core/src/cell/data-cell.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PointLike } from '@antv/g';
22
import { find, first, get, isEmpty, isEqual, isObject, merge } from 'lodash';
33
import { BaseCell } from '../cell/base-cell';
4-
import { ContentPositionParams, DEFAULT_STYLE } from '../common';
4+
import { ContentPositionParams } from '../common';
55
import { EMPTY_PLACEHOLDER } from '../common/constant/basic';
66
import {
77
CellType,
@@ -542,8 +542,9 @@ export class DataCell extends BaseCell<ViewMeta> {
542542
return (
543543
rowCell?.maxLinesByField?.[this.meta.id] ??
544544
rowCell?.maxLinesByField?.[this.meta.rowId!] ??
545+
// 透视表数值格继承行高,需按当前高度收缩 maxLines,避免高度不足时继续换行。
545546
this.getMaxLinesByCustomHeight({
546-
isCustomHeight: this.meta.height !== DEFAULT_STYLE.dataCell?.height,
547+
isCustomHeight: true,
547548
})
548549
);
549550
}

0 commit comments

Comments
 (0)