Skip to content

Commit

Permalink
fix(@clayui/core): Fixes bug when rendering the last columns visibili…
Browse files Browse the repository at this point in the history
…ty cell for dynamic rendering
  • Loading branch information
matuzalemsteles committed May 21, 2024
1 parent 5bd46ae commit 8621482
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/clay-core/src/table/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,17 @@ function RowInner<T extends Record<string, any>>(
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()),
...(columnsVisibility && count > visibleColumns.size
? [count - 1]
: []),
];
}, [columnsVisibility, visibleColumns]);
}, [columnsVisibility, items?.length, visibleColumns]);

const collection = useCollection({
children,
Expand Down

0 comments on commit 8621482

Please sign in to comment.