Skip to content

Commit 704a312

Browse files
authored
docs(AnalyticalTable): clarify NoDataComponent and row count props (#7404)
1 parent 01c0280 commit 704a312

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

packages/main/src/components/AnalyticalTable/AnalyticalTable.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const TableComp = () => {
6565
<AnalyticalTable
6666
columns={columns}
6767
data={data}
68+
visibleRows={5}
6869
onAutoResize={() => {}}
6970
onColumnsReorder={() => {}}
7071
onGroup={() => {}}

packages/main/src/components/AnalyticalTable/AnalyticalTable.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ const meta = {
178178
],
179179
highlightField: 'status',
180180
subRowsKey: 'subRows',
181+
visibleRows: 5,
181182
},
182183
argTypes: {
183184
data: { control: { disable: true } },
@@ -371,7 +372,6 @@ export const ResponsiveColumns: Story = {
371372
// @ts-expect-error: custom prop for the controls table
372373
containerWidth: 'auto',
373374
data: dataLarge,
374-
visibleRows: 5,
375375
adjustTableHeightOnPopIn: true,
376376
columns: [
377377
{
@@ -578,7 +578,6 @@ export const CustomFilter: Story = {
578578
};
579579

580580
export const NoData: Story = {
581-
args: { visibleRows: 5 },
582581
render(args, context) {
583582
const [selected, setSelected] = useState('noData');
584583
const handleChange: SegmentedButtonPropTypes['onSelectionChange'] = (e) => {

packages/main/src/components/AnalyticalTable/defaults/NoDataComponent/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ export const DefaultNoDataComponent = ({ noDataText, className }: NoDataComponen
1010
</div>
1111
);
1212
};
13+
14+
DefaultNoDataComponent.displayName = 'DefaultNoDataComponent';

packages/main/src/components/AnalyticalTable/types/index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,20 +649,22 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
649649
/**
650650
* The minimum number of rows that are displayed. If the data contains fewer entries than `minRows`, it will be filled with empty rows.
651651
*
652+
* __Note:__ To prevent the height of the table from jumping when e.g. filtering or fetching data, it's recommended setting `minRows` to the same value as `visibleRows`.
653+
*
652654
* @default 5
653655
*/
654656
minRows?: number;
655657
/**
656658
* Defines how the table will render rows.
657659
*
658660
* - __"Fixed":__ The table always has as many rows as defined in the `visibleRows` prop.
659-
* - __"Auto":__ The number of visible rows displayed depends on the height of the surrounding container.
661+
* - __"Auto":__ The number of visible rows depends on the height of the surrounding container. Since this mode can cause the table height to change when filtering, fetching data, etc., we recommend using the `"AutoWithEmptyRows"` mode instead.
660662
* - __"AutoWithEmptyRows":__ The number of rows displayed depends on the height of the surrounding container, if not enough visible rows are available, empty rows are displayed.
661663
* - __"Interactive":__ Adds a resizer to the bottom of the table to dynamically add or remove visible rows. The initial number of rows is defined by the `visibleRows` prop.
662664
*
663-
* __Default:__ `"Fixed"`
664-
*
665665
* __Note:__ When `"Auto"` or `"AutoWithEmptyRows"` is enabled, we recommend using a fixed height for the parent container.
666+
*
667+
* @default "Fixed"
666668
*/
667669
visibleRowCountMode?: AnalyticalTableVisibleRowCountMode | keyof typeof AnalyticalTableVisibleRowCountMode;
668670
/**
@@ -678,9 +680,11 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
678680
/**
679681
* The number of rows visible without going into overflow.
680682
*
681-
* __Default:__ `15`
683+
* __Note:__
684+
* - If the data contains more entries than the `visibleRow` count, a vertical scrollbar is rendered and the table goes into overflow.
685+
* - To prevent the height of the table from jumping when e.g. filtering or fetching data, it's recommended setting `minRows` to the same value as `visibleRows`.
682686
*
683-
* __Note:__ If the data contains more entries than the `visibleRow` count, a vertical scrollbar is rendered and the table goes into overflow.
687+
* @default 15
684688
*/
685689
visibleRows?: number;
686690
/**
@@ -982,11 +986,12 @@ export interface AnalyticalTablePropTypes extends Omit<CommonProps, 'title'> {
982986
* Fired when a filter is applied to a column.
983987
*/
984988
onFilter?: (e: OnFilterParam) => void;
985-
// default components
986989
/**
987990
* Component that will be rendered when the table is not loading and has no data.
988991
*
989-
* __Default:__ `DefaultNoDataComponent`
992+
* __Note:__ Although this prop accepts all React components, it is strongly recommended that you use `IllustratedMessage` with `design="Auto"` to preserve the intended design.
993+
*
994+
* @default DefaultNoDataComponent
990995
*/
991996
NoDataComponent?: ComponentType<any>;
992997

packages/main/src/enums/AnalyticalTableVisibleRowCountMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export enum AnalyticalTableVisibleRowCountMode {
99
*/
1010
Fixed = 'Fixed',
1111
/**
12-
* The number of visible rows displayed depends on the height of the surrounding container.
12+
* The number of visible rows depends on the height of the surrounding container. Since this mode can cause the table height to change when filtering, fetching data, etc., we recommend using the `"AutoWithEmptyRows"` mode instead.
1313
*
1414
* __Note:__ It's recommended to use a fixed height for the outer container.
1515
*

0 commit comments

Comments
 (0)