Skip to content

Commit

Permalink
Added console warning for Table when both subRows and `subCompone…
Browse files Browse the repository at this point in the history
…nt` exist (#2288)
  • Loading branch information
smmr-dn authored Oct 8, 2024
1 parent 7179d7b commit f0b601b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit f0b601b

Please sign in to comment.