Skip to content

Commit

Permalink
fix(flat-table): flat table contents visible behind sticky header/footer
Browse files Browse the repository at this point in the history
when the FlatTable is inside a Drawer with sticky header/footer overflow: auto should be applied

closes: FE-6674
  • Loading branch information
mihai-albu-sage committed Jul 19, 2024
1 parent 3c7eae8 commit 4f84514
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 3 deletions.
112 changes: 112 additions & 0 deletions src/components/flat-table/flat-table-test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import Link from "../../../src/components/link";
import guid from "../../__internal__/utils/helpers/guid";
import { FLAT_TABLE_THEMES } from "./flat-table.config";
import { WithSortingHeaders } from "./flat-table.stories";
import Heading from "../../../src/components/heading";
import Pager from "../../../src/components/pager";
import Drawer from "../../../src/components/drawer";

export default {
title: "Flat Table/Test",
Expand All @@ -28,6 +31,8 @@ export default {
"SortableStory",
"SubRowsAsAComponentStory",
"FlatTableSizeFocus",
"FlatTableInsideDrawer",
"TableInBox",
],
parameters: {
info: { disable: true },
Expand Down Expand Up @@ -496,3 +501,110 @@ export const FlatTableSizeFocus = () => {
</Box>
);
};

export const FlatTableInsideDrawer = () => {
return (
<Drawer
height="calc(100vh - 122px)"
expandedWidth="640px"
animationDuration="0s"
expanded
sidebar={
<Box
height="100%"
display="flex"
flexDirection="column"
overflow="hidden"
>
<Box mx={5} mb={3} mt={3}>
<Heading divider={false} title="Title title" mb={2} />
</Box>
<Box flex={1} overflowY="auto" padding={4}>
<FlatTable
hasStickyHead
hasStickyFooter
colorTheme="transparent-base"
height="100%"
footer={
<Pager
currentPage="1"
onFirst={() => {}}
onLast={() => {}}
onNext={() => {}}
onPagination={() => {}}
onPrevious={() => {}}
pageSizeSelectionOptions={[
{
id: "1",
name: 1,
},
{
id: "10",
name: 10,
},
{
id: "25",
name: 25,
},
{
id: "50",
name: 50,
},
{
id: "100",
name: 100,
},
]}
totalRecords="100"
/>
}
>
<FlatTableHead>
<FlatTableRow>
<FlatTableHeader pl={5}>Name</FlatTableHeader>
<FlatTableHeader>Location</FlatTableHeader>
<FlatTableHeader>Relationship Status</FlatTableHeader>
<FlatTableHeader>Dependents</FlatTableHeader>
</FlatTableRow>
</FlatTableHead>
<FlatTableBody>
{new Array(25)
.fill("")
.map((_, index) => index)
.map((key) => {
return (
<FlatTableRow
key={key}
expandable
subRows={[
<FlatTableRow key="sub-row-1">
<FlatTableCell>Child one</FlatTableCell>
<FlatTableCell>York</FlatTableCell>
<FlatTableCell>Single</FlatTableCell>
<FlatTableCell>2</FlatTableCell>
</FlatTableRow>,
<FlatTableRow key="sub-row-2">
<FlatTableCell>Child two</FlatTableCell>
<FlatTableCell>Edinburgh</FlatTableCell>
<FlatTableCell>Single</FlatTableCell>
<FlatTableCell>1</FlatTableCell>
</FlatTableRow>,
]}
>
<FlatTableCell>John Doe</FlatTableCell>
<FlatTableCell>London</FlatTableCell>
<FlatTableCell>Single</FlatTableCell>
<FlatTableCell>0</FlatTableCell>
</FlatTableRow>
);
})}
</FlatTableBody>
</FlatTable>
</Box>
</Box>
}
>
<div />
</Drawer>
);
};
4 changes: 1 addition & 3 deletions src/components/flat-table/flat-table.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,7 @@ export const FlatTable = ({
hasStickyHead={hasStickyHead}
colorTheme={colorTheme}
minHeight={minHeight}
overflowY={
!isInSidebar && (hasStickyHead || hasStickyFooter) ? "auto" : undefined
}
overflowY={hasStickyHead || hasStickyFooter ? "auto" : undefined}
height={addDefaultHeight && !hasMaxHeight ? "99%" : height}
maxHeight={hasMaxHeight ? "100%" : undefined}
display="flex"
Expand Down

0 comments on commit 4f84514

Please sign in to comment.