diff --git a/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.tsx b/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.tsx index 523baece08..1409a01ac4 100644 --- a/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.tsx +++ b/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.tsx @@ -1,4 +1,4 @@ -import { useMemo } from 'react'; +import { RefObject, useMemo } from 'react'; import { useTheme, TableBody, TableRow } from '@mui/material'; import { SortableTableHeader } from 'component/common/Table/SortableTableHeader/SortableTableHeader'; import { TableCell } from 'component/common/Table/TableCell/TableCell'; @@ -21,11 +21,13 @@ export const VirtualizedTable = ({ headerGroups, rows, prepareRow, + parentRef, }: { rowHeight?: number; headerGroups: HeaderGroup[]; rows: Row[]; prepareRow: (row: Row) => void; + parentRef?: RefObject; }) => { const theme = useTheme(); const rowHeight = useMemo( @@ -33,8 +35,12 @@ export const VirtualizedTable = ({ [rowHeightOverride, theme.shape.tableRowHeight] ); - const [firstRenderedIndex, lastRenderedIndex] = - useVirtualizedRange(rowHeight); + const [firstRenderedIndex, lastRenderedIndex] = useVirtualizedRange( + rowHeight, + 40, + 5, + parentRef?.current + ); const tableHeight = useMemo( () => rowHeight * rows.length + theme.shape.tableRowHeightCompact, diff --git a/frontend/src/component/playground/Playground/AdvancedPlaygroundResultsTable/AdvancedPlaygroundEnvironmentCell/AdvancedPlaygroundEnvironmentCell.tsx b/frontend/src/component/playground/Playground/AdvancedPlaygroundResultsTable/AdvancedPlaygroundEnvironmentCell/AdvancedPlaygroundEnvironmentCell.tsx index 990e01eee9..605f4eed86 100644 --- a/frontend/src/component/playground/Playground/AdvancedPlaygroundResultsTable/AdvancedPlaygroundEnvironmentCell/AdvancedPlaygroundEnvironmentCell.tsx +++ b/frontend/src/component/playground/Playground/AdvancedPlaygroundResultsTable/AdvancedPlaygroundEnvironmentCell/AdvancedPlaygroundEnvironmentCell.tsx @@ -1,5 +1,12 @@ import { ConditionallyRender } from '../../../../common/ConditionallyRender/ConditionallyRender'; -import { Box, IconButton, Popover, styled, useTheme } from '@mui/material'; +import { + Box, + IconButton, + Popover, + styled, + Typography, + useTheme, +} from '@mui/material'; import { flexRow } from '../../../../../themes/themeStyles'; import { PlaygroundResultChip } from '../../PlaygroundResultsTable/PlaygroundResultChip/PlaygroundResultChip'; import { InfoOutlined } from '@mui/icons-material'; @@ -78,6 +85,7 @@ export const AdvancedPlaygroundEnvironmentCell = ({ PaperProps={{ sx: { borderRadius: `${theme.shape.borderRadiusLarge}px`, + padding: theme.spacing(3), }, }} onClose={onClose} @@ -87,6 +95,9 @@ export const AdvancedPlaygroundEnvironmentCell = ({ horizontal: -320, }} > + + {value[0].environment} + diff --git a/frontend/src/component/playground/Playground/PlaygroundEnvironmentTable/PlaygroundEnvironmentTable.tsx b/frontend/src/component/playground/Playground/PlaygroundEnvironmentTable/PlaygroundEnvironmentTable.tsx index b305eeb91e..61d5dfc703 100644 --- a/frontend/src/component/playground/Playground/PlaygroundEnvironmentTable/PlaygroundEnvironmentTable.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundEnvironmentTable/PlaygroundEnvironmentTable.tsx @@ -1,4 +1,4 @@ -import { useMemo } from 'react'; +import React, { useMemo, useRef } from 'react'; import { useFlexLayout, useGlobalFilter, @@ -12,7 +12,7 @@ import { AdvancedPlaygroundEnvironmentFeatureSchema, PlaygroundFeatureSchema, } from 'openapi'; -import { useMediaQuery, useTheme } from '@mui/material'; +import { Box, useMediaQuery, useTheme } from '@mui/material'; import { useConditionallyHiddenColumns } from 'hooks/useConditionallyHiddenColumns'; import { FeatureStatusCell } from '../PlaygroundResultsTable/FeatureStatusCell/FeatureStatusCell'; import { FeatureResultInfoPopoverCell } from '../PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureResultInfoPopoverCell'; @@ -125,11 +125,22 @@ export const PlaygroundEnvironmentTable = ({ COLUMNS ); + const parentRef = useRef(null); + return ( - + + + ); }; diff --git a/frontend/src/component/playground/Playground/playground.utils.ts b/frontend/src/component/playground/Playground/playground.utils.ts index 8ad72ea7e4..868e0c4895 100644 --- a/frontend/src/component/playground/Playground/playground.utils.ts +++ b/frontend/src/component/playground/Playground/playground.utils.ts @@ -54,7 +54,7 @@ export const resolveResultsWidth = ( } if (results && !matches) { - return '65%'; + return '60%'; } return '50%'; diff --git a/frontend/src/hooks/useVirtualizedRange.ts b/frontend/src/hooks/useVirtualizedRange.ts index 82f38dec77..14d0e1d3e5 100644 --- a/frontend/src/hooks/useVirtualizedRange.ts +++ b/frontend/src/hooks/useVirtualizedRange.ts @@ -12,27 +12,38 @@ import { useEffect, useState } from 'react'; export const useVirtualizedRange = ( rowHeight: number, scrollOffset = 40, - dampening = 5 + dampening = 5, + parentElement?: HTMLElement | null ) => { + const parent = parentElement ? parentElement : window; + const [scrollIndex, setScrollIndex] = useState( - Math.floor(window.pageYOffset / rowHeight) + Math.floor( + (parent instanceof HTMLElement + ? parent.scrollTop + : parent.pageYOffset) / rowHeight + ) ); useEffect(() => { const handleScroll = () => { requestAnimationFrame(() => { setScrollIndex( - Math.floor(window.pageYOffset / (rowHeight * dampening)) * - dampening + Math.floor( + (parent instanceof HTMLElement + ? parent.scrollTop + : parent.pageYOffset) / + (rowHeight * dampening) + ) * dampening ); }); }; - window.addEventListener('scroll', handleScroll, { passive: true }); + parent.addEventListener('scroll', handleScroll, { passive: true }); return () => { - window.removeEventListener('scroll', handleScroll); + parent.removeEventListener('scroll', handleScroll); }; - }, [rowHeight, dampening]); + }, [rowHeight, dampening, parent]); return [scrollIndex - scrollOffset, scrollIndex + scrollOffset] as const; };