From e4c1df5b0b2aed992759484c88ef7aaa9cc9d00c Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Mon, 10 Jul 2023 16:06:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(react)=20fix=20datagrid=20column?= =?UTF-8?q?=20unique=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we had more than 1 columns with custom cells, we would get a warning about duplicate keys, because every columns got the key `actions`. We add the column index to the key to make it unique. --- .changeset/selfish-phones-enjoy.md | 5 +++++ .../src/components/DataGrid/index.spec.tsx | 21 +++++++++++++++++-- .../react/src/components/DataGrid/index.tsx | 20 ++++++++++++++---- .../react/src/components/DataGrid/utils.tsx | 7 ++++--- 4 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 .changeset/selfish-phones-enjoy.md diff --git a/.changeset/selfish-phones-enjoy.md b/.changeset/selfish-phones-enjoy.md new file mode 100644 index 0000000..ca9e447 --- /dev/null +++ b/.changeset/selfish-phones-enjoy.md @@ -0,0 +1,5 @@ +--- +"@openfun/cunningham-react": minor +--- + +fix datagrid column unique key diff --git a/packages/react/src/components/DataGrid/index.spec.tsx b/packages/react/src/components/DataGrid/index.spec.tsx index 1928629..4d56601 100644 --- a/packages/react/src/components/DataGrid/index.spec.tsx +++ b/packages/react/src/components/DataGrid/index.spec.tsx @@ -235,6 +235,17 @@ describe("", () => { highlight: true, }, { + id: "firstName2", + field: "firstName", + headerName: "First name", + }, + { + id: "lastName", + headerName: "Last Name", + renderCell: ({ row: { lastName } }) => lastName, + }, + { + id: "buttonValidator", renderCell: () => (