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

Added console warning for Table when both subRows and subComponent exist #2288

Merged
merged 8 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/cuddly-gorillas-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@itwin/itwinui-react': patch
---

Added warning log in browser when both `subRows` and `subComponent` are passed into `Table`.
10 changes: 10 additions & 0 deletions packages/itwinui-react/src/core/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,16 @@ export const Table = <
}
}

if (
process.env.NODE_ENV === 'development' &&
subComponent &&
data.some((item) => !!(item.subRows as T[] | undefined)?.length)
) {
logWarning(
`Passing both \`subComponent\` and \`data\` with \`subRows\` is not supported. There are features designed for \`subRows\` that are not compatible with \`subComponent\` and vice versa.`,
);
}

const ariaDataAttributes = Object.entries(rest).reduce(
(result, [key, value]) => {
if (key.startsWith('data-') || key.startsWith('aria-')) {
Expand Down
Loading