From 6bab9f630e26bdfb9513bb0d5fe0b4c0903f885b Mon Sep 17 00:00:00 2001 From: Jinke Li Date: Fri, 15 Mar 2024 13:53:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A0=91=E7=8A=B6?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=BC=80=E5=90=AF=E5=88=86=E9=A1=B5?= =?UTF-8?q?,=20=E8=A1=8C=E5=A4=B4=E5=B1=95=E5=BC=80=E6=94=B6=E8=B5=B7?= =?UTF-8?q?=E5=90=8E=E8=A1=A8=E6=A0=BC=E6=B8=B2=E6=9F=93=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=20close=20#2582=20(#2590)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复树状模式下开启分页, 行头展开收起后表格渲染异常 close #2582 * chore: 更新 action * docs: 完善文档 --- .github/workflows/issue-labeled.yml | 4 +- .github/workflows/pr-labeled.yml | 2 +- .../s2-core/__tests__/bugs/issue-2582-spec.ts | 49 +++++++++++++++++++ packages/s2-core/src/facet/pivot-facet.ts | 2 +- 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 packages/s2-core/__tests__/bugs/issue-2582-spec.ts diff --git a/.github/workflows/issue-labeled.yml b/.github/workflows/issue-labeled.yml index 31f9629bdf..5c3c766305 100644 --- a/.github/workflows/issue-labeled.yml +++ b/.github/workflows/issue-labeled.yml @@ -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 @@ -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: diff --git a/.github/workflows/pr-labeled.yml b/.github/workflows/pr-labeled.yml index 1f7752edd8..5888c6a7df 100644 --- a/.github/workflows/pr-labeled.yml +++ b/.github/workflows/pr-labeled.yml @@ -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. diff --git a/packages/s2-core/__tests__/bugs/issue-2582-spec.ts b/packages/s2-core/__tests__/bugs/issue-2582-spec.ts new file mode 100644 index 0000000000..f4755f351e --- /dev/null +++ b/packages/s2-core/__tests__/bugs/issue-2582-spec.ts @@ -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, + }); + }); +}); diff --git a/packages/s2-core/src/facet/pivot-facet.ts b/packages/s2-core/src/facet/pivot-facet.ts index 68c70fa5eb..77265f815a 100644 --- a/packages/s2-core/src/facet/pivot-facet.ts +++ b/packages/s2-core/src/facet/pivot-facet.ts @@ -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) =>