From ac07abea0747614d2ee349d435d24a4f58fd6ccd Mon Sep 17 00:00:00 2001 From: aleka Date: Thu, 25 Jan 2024 15:10:16 -0500 Subject: [PATCH] make sure view more is hidden when not num rows not specified (#249) --- src/components/Table.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Table.tsx b/src/components/Table.tsx index cfa2c8b..e049f36 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -125,7 +125,7 @@ export const Table = ({ selectionMode = 'single', selectionBehavior = 'toggle', slotEmpty, - initialNumRowsToShow = data.length, + initialNumRowsToShow, // shouldRowRender, // collection, @@ -142,6 +142,7 @@ export const Table = ({ }: ElementProps & StyleProps) => { const [selectedKeys, setSelectedKeys] = useState(new Set()); const [numRowsToShow, setNumRowsToShow] = useState(initialNumRowsToShow); + const enableViewMore = numRowsToShow !== undefined; const currentBreakpoints = useBreakpoints(); const shownColumns = columns.filter( @@ -217,7 +218,7 @@ export const Table = ({ } numColumns={shownColumns.length} onViewMoreClick={ - numRowsToShow !== undefined && numRowsToShow < data.length + enableViewMore && numRowsToShow < data.length ? () => setNumRowsToShow(data.length) : undefined } @@ -245,7 +246,7 @@ export const Table = ({ )} - + {(item) => ( {(columnKey) => ( @@ -982,4 +983,4 @@ Styled.ViewMoreButton = styled(Button)` width: 0.675rem; margin-left: 0.5ch; } -`; \ No newline at end of file +`;