From ca5c18777db6090ecdf8f22332aa2c7235586c09 Mon Sep 17 00:00:00 2001 From: Kevin Van Cott Date: Wed, 3 Jan 2024 09:35:28 -0600 Subject: [PATCH] fix: getRow with expanded row model and selection (#5253) --- packages/table-core/src/core/table.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/table-core/src/core/table.ts b/packages/table-core/src/core/table.ts index 4b54218152..14eb7cde8e 100644 --- a/packages/table-core/src/core/table.ts +++ b/packages/table-core/src/core/table.ts @@ -374,15 +374,20 @@ export function createTable( getRowModel: () => { return table.getPaginationRowModel() }, + //in next version, we should just pass in the row model as the optional 2nd arg getRow: (id: string, searchAll?: boolean) => { - const row = (searchAll ? table.getCoreRowModel() : table.getRowModel()) - .rowsById[id] + let row = ( + searchAll ? table.getPrePaginationRowModel() : table.getRowModel() + ).rowsById[id] if (!row) { - if (process.env.NODE_ENV !== 'production') { - throw new Error(`getRow expected an ID, but got ${id}`) + row = table.getCoreRowModel().rowsById[id] + if (!row) { + if (process.env.NODE_ENV !== 'production') { + throw new Error(`getRow could not find row with ID: ${id}`) + } + throw new Error() } - throw new Error() } return row