From 5698e7a6b404dbe2c619221eb172fdd1f1b230f5 Mon Sep 17 00:00:00 2001 From: lijinke666 Date: Tue, 17 Dec 2024 11:49:33 +0800 Subject: [PATCH 1/2] =?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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/spreadsheet/table-sheet-spec.ts | 49 ++++++++++--------- packages/s2-core/src/facet/table-facet.ts | 9 ++++ 2 files changed, 35 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; From f6188931588275545e18e94579089327f78859b5 Mon Sep 17 00:00:00 2001 From: lijinke666 Date: Tue, 17 Dec 2024 17:05:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- s2-site/docs/common/development.zh.md | 1 + 1 file changed, 1 insertion(+) 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 ```