From feab43f9aa8afe7035c46f39ddccb2c31e22b787 Mon Sep 17 00:00:00 2001 From: Jinke Li Date: Fri, 20 Dec 2024 11:54:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E8=A1=A8=E5=9C=A8=20dataCfg=20=E4=B8=BA=E7=A9=BA,=20=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=BC=80=E5=90=AF=E5=BA=8F=E5=8F=B7=E5=88=97=E6=97=B6?= =?UTF-8?q?,=20=E9=94=99=E8=AF=AF=E7=9A=84=E6=B8=B2=E6=9F=93=E4=BA=86?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E7=AC=A6=E7=9A=84=E9=97=AE=E9=A2=98=20(#3042?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复明细表在 dataCfg 为空, 同时开启序号列时, 错误的渲染了占位符的问题 * docs: 更新文档 --- .../__tests__/spreadsheet/table-sheet-spec.ts | 49 ++++++++++--------- packages/s2-core/src/facet/table-facet.ts | 9 ++++ s2-site/docs/common/development.zh.md | 1 + 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts b/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts index 846c895c5e..e26960bab4 100644 --- a/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts +++ b/packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts @@ -431,29 +431,32 @@ describe('TableSheet normal spec', () => { await expectEmptyPlaceholder(s2); }); - test('should not render empty placeholder if all fields is empty', async () => { - const s2 = new TableSheet( - getContainer(), - { ...dataCfg, fields: {}, data: [] }, - { - ...options, - frozen: {}, - seriesNumber: { - enable: false, + test.each([{ showSeriesNumber: true }, { showSeriesNumber: false }])( + 'should not render empty placeholder if all fields is empty for %o', + async ({ showSeriesNumber }) => { + const s2 = new TableSheet( + getContainer(), + { ...dataCfg, fields: {}, data: [] }, + { + ...options, + frozen: {}, + seriesNumber: { + enable: showSeriesNumber, + }, }, - }, - ); - - await s2.render(); - const [rect, icon, text] = (s2.facet as TableFacet).emptyPlaceholderGroup - .children; - - expect( - (s2.facet as TableFacet).emptyPlaceholderGroup.children, - ).toHaveLength(0); - expect(rect).not.toBeDefined(); - expect(icon).not.toBeDefined(); - expect(text).not.toBeDefined(); - }); + ); + + await s2.render(); + const [rect, icon, text] = (s2.facet as TableFacet) + .emptyPlaceholderGroup.children; + + expect( + (s2.facet as TableFacet).emptyPlaceholderGroup.children, + ).toHaveLength(0); + expect(rect).not.toBeDefined(); + expect(icon).not.toBeDefined(); + expect(text).not.toBeDefined(); + }, + ); }); }); diff --git a/packages/s2-core/src/facet/table-facet.ts b/packages/s2-core/src/facet/table-facet.ts index 1c566f91e9..aae599341b 100644 --- a/packages/s2-core/src/facet/table-facet.ts +++ b/packages/s2-core/src/facet/table-facet.ts @@ -86,6 +86,15 @@ export class TableFacet extends FrozenFacet { this.initEmptyPlaceholderGroup(); } + protected shouldRender(): boolean { + const { fields } = this.spreadsheet.dataSet; + const isOnlyContainedSeriesNumber = fields?.columns?.every( + (field) => field === SERIES_NUMBER_FIELD, + ); + + return super.shouldRender() && !isOnlyContainedSeriesNumber; + } + public render() { if (!this.shouldRender()) { return; diff --git a/s2-site/docs/common/development.zh.md b/s2-site/docs/common/development.zh.md index de69eff9c8..f91486f16b 100644 --- a/s2-site/docs/common/development.zh.md +++ b/s2-site/docs/common/development.zh.md @@ -44,5 +44,6 @@ pnpm react:test -- -u pnpm lint # 本地启动官网 +pnpm build # 首次运行官网需要先执行一次 pnpm site:start ```