From 862148209afc3952c27ab8018c4e3cb598ebfe0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matuzal=C3=A9m=20Teles?= Date: Tue, 21 May 2024 16:49:19 -0500 Subject: [PATCH] fix(@clayui/core): Fixes bug when rendering the last columns visibility cell for dynamic rendering --- packages/clay-core/src/table/Row.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/clay-core/src/table/Row.tsx b/packages/clay-core/src/table/Row.tsx index 5ec4a80a15..45cad27a47 100644 --- a/packages/clay-core/src/table/Row.tsx +++ b/packages/clay-core/src/table/Row.tsx @@ -154,7 +154,9 @@ function RowInner>( const ref = useForwardRef(outRef); const visibleKeys = useMemo(() => { - const count = React.Children.count(children); + // This is a speculation/inference about the size of items to decide + // to render a last cell as an action. + const count = items ? items.length : React.Children.count(children); return [ ...Array.from(visibleColumns.values()), @@ -162,7 +164,7 @@ function RowInner>( ? [count - 1] : []), ]; - }, [columnsVisibility, visibleColumns]); + }, [columnsVisibility, items?.length, visibleColumns]); const collection = useCollection({ children,