From e33c227fc38ecf2f1b61b3749fe8f52f8f22302f Mon Sep 17 00:00:00 2001 From: Lukas Harbarth Date: Mon, 15 Jan 2024 10:49:19 +0100 Subject: [PATCH] feat(AnalyticalTable): introduce `additionalEmptyRowsCount` prop (#5412) Fixes #5278 --- .../AnalyticalTable/AnalyticalTable.cy.tsx | 29 ++++++++++++++++++- .../src/components/AnalyticalTable/index.tsx | 19 +++++++----- .../components/AnalyticalTable/types/index.ts | 11 ++++++- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/packages/main/src/components/AnalyticalTable/AnalyticalTable.cy.tsx b/packages/main/src/components/AnalyticalTable/AnalyticalTable.cy.tsx index 95d78be26f0..a97a893a953 100644 --- a/packages/main/src/components/AnalyticalTable/AnalyticalTable.cy.tsx +++ b/packages/main/src/components/AnalyticalTable/AnalyticalTable.cy.tsx @@ -8,7 +8,6 @@ import { AnalyticalTableScaleWidthMode, AnalyticalTableSelectionBehavior, AnalyticalTableSubComponentsBehavior, - AnalyticalTableVisibleRowCountMode, Button, Input } from '../..'; @@ -1086,7 +1085,15 @@ describe('AnalyticalTable', () => { > Data 100 + { cy.findByText('Name91').should('be.visible'); cy.findByText('Rows: 150').should('be.visible'); cy.get('@more').should('have.been.calledThrice'); + + //additionalEmptyRowsCount + cy.mount(); + cy.get('[data-empty-row="true"]').should('not.exist'); + cy.findByText('Data 10').click(); + cy.findByText('Rows: 10').should('be.visible'); + cy.get('[data-empty-row="true"]').should('exist').should('not.be.visible'); + cy.findByTestId('scrollInput').typeIntoUi5Input('11{enter}', { force: true }); + cy.findByText('Rows: 60').should('be.visible'); }); it('InfiniteScroll: Tree', () => { @@ -2660,6 +2676,17 @@ describe('AnalyticalTable', () => { cy.findByText('12').should('not.be.visible'); }); + it('additionalEmptyRowsCount', () => { + cy.mount(); + cy.get('[data-empty-row]').should('not.exist'); + cy.mount(); + cy.get('[data-empty-row]').should('exist').and('not.be.visible'); + cy.mount(); + cy.get('[data-empty-row]').should('exist').and('have.length', 5).and('not.be.visible'); + cy.get('[data-component-name="AnalyticalTableBody"]').scrollTo('bottom'); + cy.get('[data-empty-row]').should('exist').and('have.length', 5).and('be.visible'); + }); + cypressPassThroughTestsFactory(AnalyticalTable, { data, columns }); }); diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index ecfc6445bb8..f22d95caa3a 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -151,6 +151,7 @@ const AnalyticalTable = forwardRef )} - {(tableState.isScrollable === undefined || tableState.isScrollable) && ( + {(additionalEmptyRowsCount || tableState.isScrollable === undefined || tableState.isScrollable) && ( { | AnalyticalTableVisibleRowCountMode | keyof typeof AnalyticalTableVisibleRowCountMode | TableVisibleRowCountMode; - + /** + * Specifies the number of additional empty rows added to the bottom of a table that is normally __non__ scrollable. + * Use this prop if you want to ensure that the table is scrollable. + * + * __Note:__ It's recommended to use this prop only if `infiniteScroll` is applied and where assessing scrollability is not possible across various resolutions or datasets. + * E.g., when using `visibleRowCountMode` with values `"Auto"` or `"AutoWithEmptyRows"`. + * + * __Note:__ This prop has no effect if the table is already scrollable without additional empty rows. + */ + additionalEmptyRowsCount?: number; /** * The number of rows visible without going into overflow. *