Skip to content

Commit

Permalink
fix: 修复树状模式下开启分页, 行头展开收起后表格渲染异常 close #2582 (#2590)
Browse files Browse the repository at this point in the history
* fix: 修复树状模式下开启分页, 行头展开收起后表格渲染异常 close #2582

* chore: 更新 action

* docs: 完善文档
  • Loading branch information
lijinke666 committed Mar 15, 2024
1 parent fae5496 commit 6bab9f6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/issue-labeled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
body: |
你好 @${{ github.event.issue.user.login }},该功能或缺陷已经在 `2.0 next 版本` 中支持或修复,`next` 版本目前处于内测中, 感谢你的支持与理解。
如有任何 `2.0 版本` 问题,请前往[讨论区](https://github.com/antvis/S2/discussions/1933),正式版预计年底发布 (文档施工中 🚧), 抢先试用:
如有任何 `2.0 版本` 问题,请前往[讨论区](https://github.com/antvis/S2/discussions/1933) 或 [查看文档](https://s2.antv.antgroup.com), 抢先试用:
```bash
yarn add @antv/s2@next
Expand All @@ -139,4 +139,4 @@ jobs:
Hello, @${{ github.event.issue.user.login }}, This feature or flaw has been supported or fixed in `2.0 next version`, `next` version is currently in private beta, thank you for your support and understanding.
Any `2.0` version issues, please go to [discussion](https://github.com/antvis/S2/discussions/1933), which released the official version is expected to the end (document 🚧) during construction, the first trial:
Any `2.0` version issues, please go to [discussion](https://github.com/antvis/S2/discussions/1933), or [view docs](https://s2.antv.antgroup.com), the first trial:
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
你好 @${{ github.event.pull_request.user.login }},感谢你的贡献, 为了让代码更健壮, 请补充相应单元测试, 如果有 API 改动, 请修改 [相应的文档](https://github.com/antvis/S2/tree/master/s2-site)
你好 @${{ github.event.pull_request.user.login }},感谢你的贡献, 为了让代码更健壮, 请根据 [贡献指南](https://s2.antv.antgroup.com/manual/contribution) 补充相应单元测试, 如果有 API 改动, 请修改 [相应的文档](https://github.com/antvis/S2/tree/master/s2-site)
Hello, @${{ github.event.pull_request.user.login }}, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the [docs](https://github.com/antvis/S2/tree/master/s2-site) if there are API changes.
Expand Down
49 changes: 49 additions & 0 deletions packages/s2-core/__tests__/bugs/issue-2582-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* 透视表分页功能,以树状结构展示行维度,切换分页,在点击角头行图标,表格数据渲染异常
* @description spec for issue #2582
* https://github.com/antvis/S2/issues/2582
*/

import { createPivotSheet } from '../util/helpers';
import type { S2Options, SpreadSheet } from '@/index';

const s2Options: S2Options = {
width: 400,
height: 400,
hierarchyType: 'tree',
pagination: {
current: 2,
pageSize: 4,
},
};

describe('PivotSheet Tree Mode Pagination Layout Tests', () => {
let s2: SpreadSheet;

beforeEach(async () => {
s2 = createPivotSheet(s2Options);
await s2.render();
});

test('should render correctly when row header wider than canvas if hierarchyCollapse enable', async () => {
s2.setOptions({
style: {
rowCell: {
collapseAll: true,
},
},
});
await s2.render(false);

expect(s2.facet.panelGroup.getBBox()).toEqual({
bottom: 92,
height: 30,
left: 122,
right: 400,
top: 62,
width: 278,
x: 122,
y: 62,
});
});
});
2 changes: 1 addition & 1 deletion packages/s2-core/src/facet/pivot-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ export class PivotFacet extends FrozenFacet {

return {
getTotalHeight: () => last(heights) || 0,
getCellOffsetY: (index: number) => heights[index],
getCellOffsetY: (index: number) => heights[index] || 0,
// 多了一个数据 [0]
getTotalLength: () => heights.length - 1,
getIndexRange: (minHeight: number, maxHeight: number) =>
Expand Down

0 comments on commit 6bab9f6

Please sign in to comment.