Skip to content

fix: dataCell 始终按当前 meta.height 计算可展示行数 - #3339

Merged
Alexzjt merged 2 commits into
nextfrom
fix/3337
Apr 27, 2026
Merged

Alexzjt merged 2 commits into
nextfrom
fix/3337

Conversation

@Alexzjt

@Alexzjt Alexzjt commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

👀 PR includes

🐛 Bugfix

🔧 Chore

  • Test case

📝 Description

改动点在 data-cell.ts (line 542):DataCell 现在会始终按当前 meta.height 计算可展示行数,而不是只有“自定义高度”时才计算。

之前的问题是默认行高下 getResizedTextMaxLines() 返回 undefined,于是回退到你配置的 dataCell.maxLines: 10,导致文本继续按 10 行换行。现在会按当前行高收缩成 1 行,textOverflow: 'ellipsis' 才能生效。

🖼️ Screenshot

Before After
❌ image ✅ image

@github-actions github-actions Bot added the next 2.0-next 版本的问题 label Apr 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

你好 @Alexzjt,非常感谢你的贡献.
为了让代码更健壮, 请根据 贡献指南 补充相应单元测试 (文档改动或其他特殊场景除外), 如果有 API 改动, 请修改 相应的文档.
同时请检查 lint 和 test 相关 CI 是否通过, 如果失败, 请点击 [Details] 按钮查看, 并根据日志修复.

Hello, @Alexzjt, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes.
At the same time, please check whether the CI related to lint and test passes. If the CI fails, please click [Details] button to check and repair according to the log.

@Alexzjt Alexzjt changed the title Fix/3337 fix: dataCell 始终按当前 meta.height 计算可展示行数 Apr 27, 2026
@github-actions github-actions Bot added the pr(fix) bug fix label Apr 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the getMaxLines logic in DataCell to ensure that maximum lines are calculated based on the current cell height, preventing text wrapping when vertical space is insufficient. This change is verified by updated test snapshots showing correct text truncation. A review comment suggests improving the code documentation by translating a Chinese comment into English and generalizing its description to include both pivot and table sheets.

Comment thread packages/s2-core/src/cell/data-cell.ts Resolved
@codecov-commenter

codecov-commenter commented Apr 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.65%. Comparing base (ecdc9c8) to head (442a685).
⚠️ Report is 799 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #3339      +/-   ##
==========================================
+ Coverage   75.77%   78.65%   +2.88%     
==========================================
  Files         257      224      -33     
  Lines       11994    12502     +508     
  Branches     2464     2842     +378     
==========================================
+ Hits         9088     9833     +745     
+ Misses       1398      959     -439     
- Partials     1508     1710     +202     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Size Change: -66 B (-0.01%)

Total Size: 744 kB

📦 View Changed
Filename Size Change
packages/s2-core/dist/s2-extends.min.js 209 kB -58 B (-0.03%)
packages/s2-core/dist/s2.min.js 311 kB -8 B (0%)
ℹ️ View Unchanged
Filename Size
packages/s2-core/dist/s2.min.css 581 B
packages/s2-react-components/dist/s2-react-components.min.css 2.55 kB
packages/s2-react-components/dist/s2-react-components.min.js 123 kB
packages/s2-react/dist/s2-react.min.css 1.3 kB
packages/s2-react/dist/s2-react.min.js 38.5 kB
packages/s2-vue/dist/s2-vue.min.css 3.8 kB
packages/s2-vue/dist/s2-vue.min.js 54.2 kB

compressed-size-action

@Alexzjt
Alexzjt merged commit 15be85d into next Apr 27, 2026
16 checks passed
@Alexzjt
Alexzjt deleted the fix/3337 branch April 27, 2026 07:02
@Alexzjt

Alexzjt commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version @antv/s2-v2.7.1-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Alexzjt

Alexzjt commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version @antv/s2-v2.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Laffery pushed a commit to Laffery/S2 that referenced this pull request Jul 17, 2026
* fix: dataCell 始终按当前 meta.height 计算可展示行数

* fix: 修复单测
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛透视表文本自动换行溢出

2 participants