From 184234659982c0bba92c2ba8b678db5214567c49 Mon Sep 17 00:00:00 2001 From: "Harbarth, Lukas" Date: Wed, 22 Jul 2020 17:01:03 +0200 Subject: [PATCH 1/3] fix(AnalyticalTable): prevent crash if unsupported rowId is set as selectedRowId, update description of props --- packages/main/src/components/AnalyticalTable/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index 04cb0dadca3..995d2352ffd 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -100,11 +100,14 @@ export interface TableProps extends CommonProps { onColumnsReordered?: (e?: CustomEvent<{ columnsNewOrder: string[]; column: unknown }>) => void; onLoadMore?: (e?: { detail: { rowCount: number } }) => void; /** - * additional options which will be passed to [react-table´s useTable hook](https://github.com/tannerlinsley/react-table/blob/master/docs/api/useTable.md#table-options) + * Additional options which will be passed to [react-table´s useTable hook](https://react-table.tanstack.com/docs/api/useTable#table-options) */ reactTableOptions?: object; tableHooks?: PluginHook[]; subRowsKey?: string; + /** + * The key must consist of a valid rowId like `{ 2: true }` or `{ ['0.2.0']: true }` for nested rows. + */ selectedRowIds?: { [key: string]: boolean }; isTreeTable?: boolean; overscanCount?: number; @@ -269,8 +272,11 @@ const AnalyticalTable: FC = forwardRef((props: TableProps, ref: Ref< useEffect(() => { toggleAllRowsSelected(false); + const validChars = /^[0-9.]+$/; for (const row in selectedRowIds) { - toggleRowSelected(row, selectedRowIds[row]); + if (row.match(validChars)) { + toggleRowSelected(row, selectedRowIds[row]); + } } }, [toggleRowSelected, toggleAllRowsSelected, selectedRowIds]); From 8e39a7cc33258fd439ab5640842c7684af983e2e Mon Sep 17 00:00:00 2001 From: "Harbarth, Lukas" Date: Wed, 22 Jul 2020 17:02:55 +0200 Subject: [PATCH 2/3] update description --- packages/main/src/components/AnalyticalTable/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index 995d2352ffd..ec5b9ac9707 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -106,7 +106,7 @@ export interface TableProps extends CommonProps { tableHooks?: PluginHook[]; subRowsKey?: string; /** - * The key must consist of a valid rowId like `{ 2: true }` or `{ ['0.2.0']: true }` for nested rows. + * The key must consist of a valid `rowId` like `{ 2: true }` or `{ ['0.2.0']: true }` for nested rows. */ selectedRowIds?: { [key: string]: boolean }; isTreeTable?: boolean; From bfa21eb78eb5f2dec565c3838dc09553144df0b5 Mon Sep 17 00:00:00 2001 From: "Harbarth, Lukas" Date: Thu, 23 Jul 2020 09:01:00 +0200 Subject: [PATCH 3/3] requested changes --- packages/main/src/components/AnalyticalTable/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/main/src/components/AnalyticalTable/index.tsx b/packages/main/src/components/AnalyticalTable/index.tsx index ec5b9ac9707..5cdb1548026 100644 --- a/packages/main/src/components/AnalyticalTable/index.tsx +++ b/packages/main/src/components/AnalyticalTable/index.tsx @@ -106,7 +106,7 @@ export interface TableProps extends CommonProps { tableHooks?: PluginHook[]; subRowsKey?: string; /** - * The key must consist of a valid `rowId` like `{ 2: true }` or `{ ['0.2.0']: true }` for nested rows. + * The key must consist of a valid `rowId` like `{ 2: true }` or `{ '0.2.0': true }` for nested rows. */ selectedRowIds?: { [key: string]: boolean }; isTreeTable?: boolean; @@ -272,9 +272,9 @@ const AnalyticalTable: FC = forwardRef((props: TableProps, ref: Ref< useEffect(() => { toggleAllRowsSelected(false); - const validChars = /^[0-9.]+$/; + const validChars = /^(\d\.)*\d$/; for (const row in selectedRowIds) { - if (row.match(validChars)) { + if (validChars.test(row)) { toggleRowSelected(row, selectedRowIds[row]); } }