Skip to content

Commit

Permalink
Merge pull request #5822 from matuzalemsteles/dynamic-renderer-table
Browse files Browse the repository at this point in the history
fix(@clayui/core): Fixes bug when rendering the last columns visibility cell for dynamic rendering
  • Loading branch information
matuzalemsteles authored May 21, 2024
2 parents 5bd46ae + 8621482 commit 3073159
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 3073159

Please sign in to comment.