Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGridPro] Keep bottom pinned row at the bottom #13313

Merged
merged 15 commits into from
Jul 9, 2024
romgrk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function GridVirtualScroller(props: GridVirtualScrollerProps) {
</RenderZone>
</Content>

{rows.length > 0 && <SpaceFiller />}
<SpaceFiller rowsLength={rows.length} />

<BottomContainer>
<rootProps.slots.pinnedRows position="bottom" virtualScroller={virtualScroller} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,29 @@ const Pinned = styled('div')({
position: 'sticky',
height: '100%',
boxSizing: 'border-box',
borderTop: '1px solid var(--DataGrid-rowBorderColor)',
borderTop: '1px solid var(--rowBorderColor)',
backgroundColor: 'var(--DataGrid-pinnedBackground)',
});
const PinnedLeft = styled(Pinned)({
left: 0,
borderRight: '1px solid var(--DataGrid-rowBorderColor)',
borderRight: '1px solid var(--rowBorderColor)',
});
const PinnedRight = styled(Pinned)({
right: 0,
borderLeft: '1px solid var(--DataGrid-rowBorderColor)',
borderLeft: '1px solid var(--rowBorderColor)',
});

const Main = styled('div')({
flexGrow: 1,
borderTop: '1px solid var(--DataGrid-rowBorderColor)',
borderTop: '1px solid var(--rowBorderColor)',
});

function GridVirtualScrollerFiller() {
type Props = {
/** The number of rows */
rowsLength: number;
};

function GridVirtualScrollerFiller({ rowsLength }: Props) {
const apiRef = useGridApiContext();
const {
viewportOuterSize,
Expand All @@ -54,7 +59,16 @@ function GridVirtualScrollerFiller() {
}

return (
<Filler className={gridClasses.filler} role="presentation" style={{ height }}>
<Filler
className={gridClasses.filler}
role="presentation"
style={
{
height,
'--rowBorderColor': rowsLength === 0 ? 'transparent' : 'var(--DataGrid-rowBorderColor)',
} as React.CSSProperties
}
>
{leftPinnedWidth > 0 && (
<PinnedLeft
className={gridClasses['filler--pinnedLeft']}
Expand Down
Loading