diff --git a/src/components/Table/src/hooks/useCustomRow.ts b/src/components/Table/src/hooks/useCustomRow.ts index 56187208e..1a5aac858 100644 --- a/src/components/Table/src/hooks/useCustomRow.ts +++ b/src/components/Table/src/hooks/useCustomRow.ts @@ -40,7 +40,7 @@ export function useCustomRow( function handleClick() { const { rowSelection, rowKey, clickToRowSelect } = unref(propsRef); if (!rowSelection || !clickToRowSelect) return; - const keys = getSelectRowKeys(); + const keys = getSelectRowKeys() || []; const key = getKey(record, rowKey, unref(getAutoCreateKey)); if (!key) return; diff --git a/src/components/Table/src/hooks/useRowSelection.ts b/src/components/Table/src/hooks/useRowSelection.ts index 3439a223b..ed19b072a 100644 --- a/src/components/Table/src/hooks/useRowSelection.ts +++ b/src/components/Table/src/hooks/useRowSelection.ts @@ -66,13 +66,13 @@ export function useRowSelection( selectedRowKeysRef.value = rowKeys; const allSelectedRows = findNodeAll( toRaw(unref(tableData)).concat(toRaw(unref(selectedRowRef))), - (item) => rowKeys.includes(item[unref(getRowKey) as string]), + (item) => rowKeys?.includes(item[unref(getRowKey) as string]), { children: propsRef.value.childrenColumnName ?? 'children', }, ); const trueSelectedRows: any[] = []; - rowKeys.forEach((key: string) => { + rowKeys?.forEach((key: string) => { const found = allSelectedRows.find((item) => item[unref(getRowKey) as string] === key); found && trueSelectedRows.push(found); }); diff --git a/src/views/demo/table/FormTable.vue b/src/views/demo/table/FormTable.vue index 23300aa7c..fc565edfe 100644 --- a/src/views/demo/table/FormTable.vue +++ b/src/views/demo/table/FormTable.vue @@ -1,8 +1,5 @@