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 ```