Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@clayui/core): Fixes bug when rendering the last columns visibility cell for dynamic rendering #5822

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading