From 06a5476e93320794c24d50c2d927988da41efec2 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 9 Jun 2025 11:11:39 -0600 Subject: [PATCH] made a sticky header for the table --- src/common/ResponsiveTable.tsx | 15 +++++++++++---- src/pages/Devices.tsx | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/common/ResponsiveTable.tsx b/src/common/ResponsiveTable.tsx index ee1e9dd..cce8276 100644 --- a/src/common/ResponsiveTable.tsx +++ b/src/common/ResponsiveTable.tsx @@ -56,6 +56,11 @@ const useStyles = makeStyles((theme: Theme) => { backgroundColor: "rgba(150, 150, 150, 0.15)", } }, + stickyHeader: { + position: "sticky", + top: 0, + zIndex: 300 //giving a really high z-index to make sure nothing is in front of it + } })}, ); @@ -100,6 +105,7 @@ interface Props { setOrder?: React.Dispatch>; endTitleElement?: string | JSX.Element | (() => string | JSX.Element); loadMore?: () => void + stickyHeader?: boolean } export default function ResponsiveTable(props: Props) { @@ -133,7 +139,8 @@ export default function ResponsiveTable(props: Props) { setOrderBy, order, setOrder, - loadMore + loadMore, + stickyHeader } = props const classes = useStyles(); const columns = typeof(props.columns) === "function" ? props.columns() : props.columns @@ -432,9 +439,9 @@ export default function ResponsiveTable(props: Props) { } return ( - + - + @@ -629,6 +636,6 @@ export default function ResponsiveTable(props: Props) { ) })} - + ) } \ No newline at end of file diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx index 9e8bb0d..7571168 100644 --- a/src/pages/Devices.tsx +++ b/src/pages/Devices.tsx @@ -735,6 +735,7 @@ export default function Devices() { title={} subtitle={subtitle} + stickyHeader rows={devices} renderGutter={ isMobile ? gutter : undefined } columns={columns}