Skip to content

Commit 8ba09dd

Browse files
authored
feat(AnalyticalTable): fire onLoadMore when resizing in Interactive visibleRowCountMode (#5203)
Closes #5201 This PR also moves the `index.tsx` types of the AnalyticalTable into a separate folder to prevent circular imports.
1 parent 32f6a15 commit 8ba09dd

File tree

9 files changed

+635
-597
lines changed

9 files changed

+635
-597
lines changed

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Virtualizer } from '@tanstack/react-virtual';
22
import { ThemingParameters } from '@ui5/webcomponents-react-base';
33
import React, { forwardRef, Fragment } from 'react';
44
import { createUseStyles } from 'react-jss';
5-
import type { DivWithCustomScrollProp } from '../index.js';
5+
import type { DivWithCustomScrollProp } from '../types/index.js';
66
import { ColumnHeader } from './index.js';
77

88
const styles = {

packages/main/src/components/AnalyticalTable/ColumnHeader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { createUseStyles } from 'react-jss';
1818
import { CustomThemingParameters } from '../../../themes/CustomVariables.js';
1919
import { Icon } from '../../../webComponents/Icon/index.js';
2020
import { Text } from '../../Text/index.js';
21-
import type { DivWithCustomScrollProp } from '../index.js';
2221
import type { ColumnType } from '../types/ColumnType.js';
22+
import type { DivWithCustomScrollProp } from '../types/index.js';
2323
import { ColumnHeaderModal } from './ColumnHeaderModal.js';
2424

2525
export interface ColumnHeaderProps {

packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useVirtualizer } from '@tanstack/react-virtual';
33
import { clsx } from 'clsx';
44
import type { MutableRefObject, ReactNode } from 'react';
55
import React, { useCallback, useMemo, useRef } from 'react';
6-
import type { AnalyticalTablePropTypes, DivWithCustomScrollProp } from '../index.js';
76
import type { ScrollToRefType } from '../interfaces.js';
7+
import type { AnalyticalTablePropTypes, DivWithCustomScrollProp } from '../types/index.js';
88
import { getSubRowsByString } from '../util/index.js';
99
import { EmptyRow } from './EmptyRow.js';
1010
import { RowSubComponent as SubComponent } from './RowSubComponent.js';

packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBodyContainer.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { enrichEventWithDetails } from '@ui5/webcomponents-react-base';
22
import type { MutableRefObject } from 'react';
33
import React, { useCallback, useEffect, useRef, useState } from 'react';
4-
import type { AnalyticalTablePropTypes } from '../index.js';
4+
import type { AnalyticalTablePropTypes } from '../types/index.js';
55

66
interface VirtualTableBodyContainerProps {
77
tableBodyHeight: number;
@@ -81,13 +81,7 @@ export const VirtualTableBodyContainer = (props: VirtualTableBodyContainerProps)
8181
(popInRowHeight === internalRowHeight ? visibleRows : Math.floor(tableBodyHeight / popInRowHeight));
8282
if (rows.length - currentLastRow < infiniteScrollThreshold) {
8383
if (!firedInfiniteLoadEvents.current.has(rows.length)) {
84-
const rootNodes = rows.filter((row) => row.depth === 0);
85-
onLoadMore(
86-
enrichEventWithDetails(event, {
87-
rowCount: rootNodes.length,
88-
totalRowCount: rows.length
89-
})
90-
);
84+
onLoadMore(event);
9185
}
9286
firedInfiniteLoadEvents.current.add(rows.length);
9387
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ interface VerticalResizerProps {
4646
hasPopInColumns: boolean;
4747
popInRowHeight: number;
4848
portalContainer: Element;
49+
rowsLength: number;
50+
visibleRows: number;
51+
handleOnLoadMore: (e: Event) => void;
4952
}
5053

5154
const isTouchEvent = (e, touchEvent) => {
@@ -63,7 +66,10 @@ export const VerticalResizer = (props: VerticalResizerProps) => {
6366
internalRowHeight,
6467
hasPopInColumns,
6568
popInRowHeight,
66-
portalContainer
69+
portalContainer,
70+
rowsLength,
71+
visibleRows,
72+
handleOnLoadMore
6773
} = props;
6874
const classes = useStyles();
6975
const startY = useRef(null);
@@ -156,6 +162,14 @@ export const VerticalResizer = (props: VerticalResizerProps) => {
156162
};
157163
}, []);
158164

165+
const isInitial = useRef(true);
166+
useEffect(() => {
167+
if (!isInitial.current && rowsLength <= visibleRows) {
168+
handleOnLoadMore({ type: 'tableGrow' } as Event);
169+
}
170+
isInitial.current = false;
171+
}, [rowsLength, visibleRows]);
172+
159173
const canRenderPortal = useCanRenderPortal();
160174
if (!canRenderPortal) {
161175
return null;

packages/main/src/components/AnalyticalTable/hooks/useDynamicColumnWidths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMemo } from 'react';
22
import { AnalyticalTableScaleWidthMode } from '../../../enums/index.js';
33
import { DEFAULT_COLUMN_WIDTH } from '../defaults/Column/index.js';
4-
import type { AnalyticalTableColumnDefinition } from '../index.js';
4+
import type { AnalyticalTableColumnDefinition } from '../types/index.js';
55

66
const ROW_SAMPLE_SIZE = 20;
77
const MAX_WIDTH = 700;

0 commit comments

Comments
 (0)