From 253f778959fb1a0ad5630acc39b17e024c72c0e1 Mon Sep 17 00:00:00 2001 From: Philipp S Date: Thu, 10 Nov 2022 12:24:31 -0500 Subject: [PATCH 1/3] Update `DataTable` to properly inherit `columnTypes` in summary rows --- polaris-react/src/components/DataTable/DataTable.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polaris-react/src/components/DataTable/DataTable.tsx b/polaris-react/src/components/DataTable/DataTable.tsx index a62fac6c2e6..ff3cda126fe 100644 --- a/polaris-react/src/components/DataTable/DataTable.tsx +++ b/polaris-react/src/components/DataTable/DataTable.tsx @@ -854,6 +854,8 @@ class DataTableInner extends PureComponent { const id = `totals-cell-${index}`; const {truncate = false, verticalAlign} = this.props; + const {columnContentTypes} = this.props; + let content; let contentType; @@ -862,7 +864,7 @@ class DataTableInner extends PureComponent { } if (total !== '' && index > 0) { - contentType = 'numeric'; + contentType = columnContentTypes[index]; content = total; } From 3a07a29126cabf1496d6d0c10e4cd3a659016025 Mon Sep 17 00:00:00 2001 From: Philipp S Date: Thu, 10 Nov 2022 12:26:17 -0500 Subject: [PATCH 2/3] Adds changeset --- .changeset/brave-ways-carry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/brave-ways-carry.md diff --git a/.changeset/brave-ways-carry.md b/.changeset/brave-ways-carry.md new file mode 100644 index 00000000000..3b266acc88f --- /dev/null +++ b/.changeset/brave-ways-carry.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris': patch +--- + +Fixes bug where `DataTable` summary row would not properly inherit type defined in `columnContentTypes` prop From 1238069b095a14a09d1e59dbee81e4cc6760893f Mon Sep 17 00:00:00 2001 From: Philipp S Date: Thu, 10 Nov 2022 14:40:53 -0500 Subject: [PATCH 3/3] Combined destructuring in `DataTable` and updated changeset copy --- .changeset/brave-ways-carry.md | 2 +- polaris-react/src/components/DataTable/DataTable.tsx | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.changeset/brave-ways-carry.md b/.changeset/brave-ways-carry.md index 3b266acc88f..b0dc24804ad 100644 --- a/.changeset/brave-ways-carry.md +++ b/.changeset/brave-ways-carry.md @@ -2,4 +2,4 @@ '@shopify/polaris': patch --- -Fixes bug where `DataTable` summary row would not properly inherit type defined in `columnContentTypes` prop +Fixed a bug where `DataTable` summary row would not properly inherit type defined in `columnContentTypes` prop diff --git a/polaris-react/src/components/DataTable/DataTable.tsx b/polaris-react/src/components/DataTable/DataTable.tsx index ff3cda126fe..ba3689bb8ad 100644 --- a/polaris-react/src/components/DataTable/DataTable.tsx +++ b/polaris-react/src/components/DataTable/DataTable.tsx @@ -852,9 +852,7 @@ class DataTableInner extends PureComponent { }) => { const fixedFirstColumns = this.fixedFirstColumns(); const id = `totals-cell-${index}`; - const {truncate = false, verticalAlign} = this.props; - - const {columnContentTypes} = this.props; + const {truncate = false, verticalAlign, columnContentTypes} = this.props; let content; let contentType;