From 40051bc8505285386a135cf8b9f630ca482c9585 Mon Sep 17 00:00:00 2001 From: rayetzki Date: Thu, 20 Jan 2022 10:21:50 +0200 Subject: [PATCH 1/2] [VirtualList, DataTable]: Fix recalculation of estimatedHeight --- .../examples/virtualList/Advanced.example.tsx | 4 +- .../__snapshots__/DataTable.test.tsx.snap | 55 +++++++++++++++++++ .../DataTableHeaderRow.test.tsx.snap | 10 ++++ .../src/table/DataTableRowContainer.tsx | 1 + uui/hooks/useVirtualList.ts | 7 +-- 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/app/src/docs/examples/virtualList/Advanced.example.tsx b/app/src/docs/examples/virtualList/Advanced.example.tsx index 67350bac5e..1562f905bc 100644 --- a/app/src/docs/examples/virtualList/Advanced.example.tsx +++ b/app/src/docs/examples/virtualList/Advanced.example.tsx @@ -22,14 +22,14 @@ export default function AdvancedVirtualList() { const citiesDataSource = useLazyDataSource({ api: svc.api.demo.cities }, []); const { getVisibleRows, getListProps } = citiesDataSource.useView(value, onValueChange, {}); - const { listContainerRef, offsetY, handleScroll, scrollContainerRef } = useVirtualList({ + const { listContainerRef, offsetY, handleScroll, scrollContainerRef, estimatedHeight } = useVirtualList({ value, onValueChange, rowsCount: getListProps().rowsCount, }); return (
-
+
    { getVisibleRows().map(row => (
  • diff --git a/loveship/components/tables/__tests__/__snapshots__/DataTable.test.tsx.snap b/loveship/components/tables/__tests__/__snapshots__/DataTable.test.tsx.snap index d9d517050c..6ed6bd08d8 100644 --- a/loveship/components/tables/__tests__/__snapshots__/DataTable.test.tsx.snap +++ b/loveship/components/tables/__tests__/__snapshots__/DataTable.test.tsx.snap @@ -43,6 +43,11 @@ exports[`DataTable should be rendered correctly 1`] = ` >
    extends React.Component< wrapFixedSection = (cells: DataColumnProps[], direction: 'left' | 'right') => (
    { - if (!listContainer.current) return undefined; - return listContainer.current.offsetTop; - }, [listContainer.current]); + const listOffset = React.useMemo(() => listContainer.current?.offsetTop || 0, [listContainer.current]); const updateRowHeights = React.useCallback(() => { - if (!listContainer.current || (listContainer.current.offsetTop > 0 && !listOffset)) return; + if (!listContainer.current) return; Array.from(listContainer.current.children).forEach((node, index) => { const topIndex = value?.topIndex || 0; From be518b85d2573b76cd092a59846663f939aba461 Mon Sep 17 00:00:00 2001 From: rayetzki Date: Thu, 20 Jan 2022 15:29:50 +0200 Subject: [PATCH 2/2] [DataTableHeaderCell]: Remove key to allow dnd, resizing --- epam-promo/components/tables/DataTableHeaderRow.tsx | 1 - loveship/components/tables/DataTableHeaderRow.tsx | 1 - uui-components/src/table/DataTableRowContainer.tsx | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/epam-promo/components/tables/DataTableHeaderRow.tsx b/epam-promo/components/tables/DataTableHeaderRow.tsx index 05e6a3b6d2..075318dd69 100644 --- a/epam-promo/components/tables/DataTableHeaderRow.tsx +++ b/epam-promo/components/tables/DataTableHeaderRow.tsx @@ -10,7 +10,6 @@ export const DataTableHeaderRow = withMods [css.root], mods => ({ renderCell: props => [css.root], mods => ({ renderCell: props => extends React.Component< [uuiDataTableRowContainer.uuiTableFixedSectionLeft]: direction === 'left', [css.fixedColumnsSectionRight]: direction === 'right', [uuiDataTableRowContainer.uuiTableFixedSectionRight]: direction === 'right', - })}> + }) }> { this.renderCells(cells) } { direction === 'right' &&
    } { direction === 'left' &&
    }