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

fix(AnalyticalTable): prevent crash if unsupported rowId is set as selectedRowId #615

Merged
merged 3 commits into from
Jul 23, 2020
Merged
Changes from 2 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
10 changes: 8 additions & 2 deletions packages/main/src/components/AnalyticalTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>[];
subRowsKey?: string;
/**
* The key must consist of a valid `rowId` like `{ 2: true }` or `{ ['0.2.0']: true }` for nested rows.
Lukas742 marked this conversation as resolved.
Show resolved Hide resolved
*/
selectedRowIds?: { [key: string]: boolean };
isTreeTable?: boolean;
overscanCount?: number;
Expand Down Expand Up @@ -269,8 +272,11 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<

useEffect(() => {
toggleAllRowsSelected(false);
const validChars = /^[0-9.]+$/;
Lukas742 marked this conversation as resolved.
Show resolved Hide resolved
for (const row in selectedRowIds) {
toggleRowSelected(row, selectedRowIds[row]);
if (row.match(validChars)) {
Lukas742 marked this conversation as resolved.
Show resolved Hide resolved
toggleRowSelected(row, selectedRowIds[row]);
}
}
}, [toggleRowSelected, toggleAllRowsSelected, selectedRowIds]);

Expand Down