diff --git a/packages/gamut/src/DataList/Tables/Rows/TableRow.tsx b/packages/gamut/src/DataList/Tables/Rows/TableRow.tsx index 817418c6bd..776618f9fd 100644 --- a/packages/gamut/src/DataList/Tables/Rows/TableRow.tsx +++ b/packages/gamut/src/DataList/Tables/Rows/TableRow.tsx @@ -9,6 +9,7 @@ import { import { Text } from '../../..'; import { ListCol, ListRow } from '../../../List'; import { ColProps } from '../../../List/elements'; +import { useListContext } from '../../../List/ListProvider'; import { Shimmer } from '../../../Loading/Shimmer'; import { ExpandControl, SelectControl } from '../../Controls'; import { useControlContext } from '../../hooks/useListControls'; @@ -47,7 +48,10 @@ export const TableRow: DataRow = ({ prefixId, } = useControlContext(); - const listColProps = { showOverflow }; + const { variant, listType } = useListContext(); + const dataTablePadding = listType === 'table' && variant === 'table'; + + const listColProps = { dataTablePadding, showOverflow }; const controlIndices = useMemo(() => { const controlIndices = new Map(); diff --git a/packages/gamut/src/List/ListCol.tsx b/packages/gamut/src/List/ListCol.tsx index 1397710844..0aa54bcedc 100644 --- a/packages/gamut/src/List/ListCol.tsx +++ b/packages/gamut/src/List/ListCol.tsx @@ -27,6 +27,7 @@ export const ListCol = forwardRef( as={colEl} columnHeader={columnHeader} delimiter={sticky && activeVariants.variant === 'table'} + lastChildPadding={!(type === 'expandControl')} ref={ref} sticky={sticky} type={isOrderedHeader ? 'orderedHeader' : type} diff --git a/packages/gamut/src/List/__tests__/List.test.tsx b/packages/gamut/src/List/__tests__/List.test.tsx index 19beb4276d..d6bec4512d 100644 --- a/packages/gamut/src/List/__tests__/List.test.tsx +++ b/packages/gamut/src/List/__tests__/List.test.tsx @@ -61,12 +61,11 @@ describe('List', () => { : 'paddingRight'; const { view } = renderView(); - const rowEl = view.getByRole('listitem'); const colEl = view.getByText('Hello'); expect(colEl).not.toHaveStyle({ py: 16 }); - expect(rowEl).toHaveStyle({ [paddingLeft]: theme.spacing[8] }); - expect(rowEl).toHaveStyle({ [paddingRight]: theme.spacing[8] }); + expect(colEl).toHaveStyle({ [paddingLeft]: theme.spacing[8] }); + expect(colEl).toHaveStyle({ [paddingRight]: theme.spacing[8] }); expect(colEl).not.toHaveStyle({ position: 'sticky' }); }); diff --git a/packages/gamut/src/List/elements.tsx b/packages/gamut/src/List/elements.tsx index 6b4abbb4d3..3f4b3476fe 100644 --- a/packages/gamut/src/List/elements.tsx +++ b/packages/gamut/src/List/elements.tsx @@ -99,9 +99,6 @@ const interactiveState = states({ const spacingVariants = variant({ prop: 'spacing', - base: { - px: { _: 8, c_base: 0, c_sm: 8 }, - }, variants: { normal: { rowGap: { _: 0, c_base: 8, c_sm: 0 }, @@ -376,6 +373,23 @@ const columnStates = states({ whiteSpace: 'normal', alignItems: 'flex-end', }, + dataTablePadding: { + '&:first-of-type': { + pl: 8, + }, + '&:last-of-type': { + pr: 8, + }, + }, + /** + * We add this to every RowEl except expandable DataList because it causes a layout shift. + * In that case, the padding is instead added directly to the Expandable control. + */ + lastChildPadding: { + '&:last-of-type': { + pr: 8, + }, + }, wrap: { whiteSpace: 'normal', }, @@ -392,6 +406,9 @@ const columnSpacing = variant({ prop: 'spacing', base: { px: { _: 0, c_base: 8, c_sm: 0 }, + '&:first-of-type': { + pl: 8, + }, }, variants: { normal: {